﻿using System;
using System.Collections.Generic;
using System.Text;

using RaisingStudio.Data.Common;
using RaisingStudio.Data.Common.Factories;
using RaisingStudio.Data.Expressions;
using RaisingStudio.Data.Common.Builders.Expressions;
using RaisingStudio.Data.Common.Managers;

namespace RaisingStudio.Data.Providers.Adapters
{
    /// <summary>
    /// datatable DataAdapter.
    /// </summary>
    public partial class DataTableAdapter : DataAdapterBase, RaisingStudio.Data.Common.IDataTableAdapter
    {
        #region static member
        /// <summary>
        /// Sets Command current value.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="values">data value array.</param>
        /// <param name="command">Command.</param>
        public static void SetCurrentValue(string[] columnNames, object[] values, System.Data.IDbCommand command)
        {
            for (int i = 0; i < columnNames.Length; i++)
            {
                string columnName = columnNames[i];
                System.Data.IDbDataParameter currentMappingParameter = RaisingStudio.Data.Common.Builders.CommandBuilder.GetCurrentMappingParameterByColumn(command.Parameters, columnName);
                if (currentMappingParameter != null)
                {
                    object value = values[i];
                    if (value == null)
                    {
                        currentMappingParameter.Value = System.DBNull.Value;
                    }
                    else
                    {
                        currentMappingParameter.Value = value;
                    }
                }
            }
        }
        /// <summary>
        /// Sets Command current value.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="values">value dictionary.</param>
        /// <param name="command">Command.</param>
        public static void SetCurrentValue(string[] columnNames, Dictionary<string, object> values, System.Data.IDbCommand command)
        {
            foreach (string columnName in columnNames)
            {
                System.Data.IDbDataParameter currentMappingParameter = RaisingStudio.Data.Common.Builders.CommandBuilder.GetCurrentMappingParameterByColumn(command.Parameters, columnName);
                if (currentMappingParameter != null)
                {
                    object value = values[columnName];
                    if (value == null)
                    {
                        currentMappingParameter.Value = System.DBNull.Value;
                    }
                    else
                    {
                        currentMappingParameter.Value = value;
                    }
                }
            }
        }

        /// <summary>
        /// Sets Command The original values.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="originalValues">data value array.</param>
        /// <param name="command">Command.</param>
        public static void SetOriginalValue(string[] columnNames, object[] originalValues, System.Data.IDbCommand command)
        {
            for (int i = 0; i < columnNames.Length; i++)
            {
                string columnName = columnNames[i];
                System.Data.IDbDataParameter originalMappingParameter = RaisingStudio.Data.Common.Builders.CommandBuilder.GetOriginalMappingParameterByColumn(command.Parameters, columnName);
                if (originalMappingParameter != null)
                {
                    object originalValue = originalValues[i];
                    if ((originalValue == null) || (originalValue == System.DBNull.Value))
                    {
                        System.Data.IDbDataParameter nullMappingParameter = RaisingStudio.Data.Common.Builders.CommandBuilder.GetNullMappingParameterByColumn(command.Parameters, columnName);
                        if (nullMappingParameter != null)
                        {
                            nullMappingParameter.Value = 1;
                        }
                        originalMappingParameter.Value = System.DBNull.Value;
                    }
                    else
                    {
                        originalMappingParameter.Value = originalValue;
                    }
                }
            }
        }
        /// <summary>
        /// Sets Command The original values.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="originalValues">value dictionary.</param>
        /// <param name="command">Command.</param>
        public static void SetOriginalValue(string[] columnNames, Dictionary<string, object> originalValues, System.Data.IDbCommand command)
        {
            foreach (string columnName in columnNames)
            {
                System.Data.IDbDataParameter originalMappingParameter = RaisingStudio.Data.Common.Builders.CommandBuilder.GetOriginalMappingParameterByColumn(command.Parameters, columnName);
                if (originalMappingParameter != null)
                {
                    object originalValue = originalValues[columnName];
                    if ((originalValue == null) || (originalValue == System.DBNull.Value))
                    {
                        System.Data.IDbDataParameter nullMappingParameter = RaisingStudio.Data.Common.Builders.CommandBuilder.GetNullMappingParameterByColumn(command.Parameters, columnName);
                        if (nullMappingParameter != null)
                        {
                            nullMappingParameter.Value = 1;
                        }
                        originalMappingParameter.Value = System.DBNull.Value;
                    }
                    else
                    {
                        originalMappingParameter.Value = originalValue;
                    }
                }
            }
        }
        #endregion

        #region Common property 
        protected System.Type dataTableType;
        /// <summary>
        /// datatable Type.
        /// </summary>
        public System.Type DataTableType
        {
            get
            {
                return this.dataTableType;
            }
        }

        protected string definitionName;
        /// <summary>
        /// datatable definition name.
        /// </summary>
        public string DefinitionName
        {
            get
            {
                return this.definitionName;
            }
        }


        protected DataAdapterFactory dataAdapterFactory;
        /// <summary>
        /// DataAdapter factory.
        /// </summary>
        public DataAdapterFactory DataAdapterFactory
        {
            get
            {
                return this.dataAdapterFactory;
            }
        }

        protected System.Data.IDbDataAdapter defaultDataAdapter;
        /// <summary>
        /// DataAdapter.
        /// </summary>
        public System.Data.IDbDataAdapter DefaultDataAdapter
        {
            get
            {
                if (this.defaultDataAdapter == null)
                {
                    this.defaultDataAdapter = CreateDataAdapter(true);
                }
                return this.defaultDataAdapter;
            }
        }

        protected RaisingStudio.Data.Common.Builders.CommandBuilder commandBuilder;
        /// <summary>
        /// Command builder.
        /// </summary>
        public RaisingStudio.Data.Common.Builders.CommandBuilder CommandBuilder
        {
            get
            {
                if (this.commandBuilder == null)
                {
                    this.commandBuilder = CreateCommandBuilder();
                }
                return this.commandBuilder;
            }
        }

        protected System.Data.Common.DataTableMapping defaultDataTableMapping;
        /// <summary>
        /// default Data table mapping.
        /// </summary>
        public System.Data.Common.DataTableMapping DefaultDataTableMapping
        {
            get
            {
                if (this.defaultDataTableMapping == null)
                {
                    if (this.defaultDataAdapter != null)
                    {
                        this.defaultDataTableMapping = ((this.defaultDataAdapter as System.Data.IDataAdapter).TableMappings[0] as System.Data.Common.DataTableMapping);
                    }
                    else
                    {
                        this.defaultDataTableMapping = this.CommandBuilder.CommonCommandBuilder.GetDataTableMapping();
                    }
                }
                return this.defaultDataTableMapping;
            }
        }

        protected bool cloneDataTable = true;
        /// <summary>
        /// Create same structure of Datatable.
        /// </summary>
        public bool CloneDataTable
        {
            get
            {
                return this.cloneDataTable;
            }
        }

        private bool _cacheDefalutCommand = true;

        public bool CacheDefalutCommand
        {
            get { return _cacheDefalutCommand; }
            set { _cacheDefalutCommand = value; }
        }
        #endregion

        #region Constructor
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="dataTableType">Type of data object.</param>
        public DataTableAdapter(System.Type dataTableType)
        {
            this.dataTableType = dataTableType;
            this.connection = ConnectionFactory.CreateConnection();
            DatabaseType databaseType;
            string providerName;
            ConnectionFactory.GetConnectionSetting(out databaseType, out providerName);
            this._databaseType = databaseType;
            this._providerName = providerName;
            this.transactionManager = TransactionManagerFactory.CreateTransactionManager(this.connection);
            this.dataAdapterFactory = new DataAdapterFactory(this.connection, this._databaseType, this._providerName);
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="dataTableType">Type of data object.</param>
        /// <param name="connection">database connection.</param>
        public DataTableAdapter(System.Type dataTableType, System.Data.IDbConnection connection)
        {
            this.dataTableType = dataTableType;
            this.connection = connection;
            this.transactionManager = TransactionManagerFactory.CreateTransactionManager(this.connection);
            this.dataAdapterFactory = new DataAdapterFactory(this.connection);
        }

        public DataTableAdapter(System.Type dataTableType, System.Data.IDbConnection connection, DatabaseType databaseType, string providerName)
        {
            this.dataTableType = dataTableType;
            this.connection = connection;
            this._databaseType = databaseType;
            this._providerName = providerName;
            this.transactionManager = TransactionManagerFactory.CreateTransactionManager(this.connection);
            this.dataAdapterFactory = new DataAdapterFactory(this.connection, this._databaseType, this._providerName);
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="dataTableType">Type of data object.</param>
        /// <param name="transactionManager">database transaction manager.</param>
        public DataTableAdapter(System.Type dataTableType, TransactionManager transactionManager, ILogManager logManager)
        {
            this.dataTableType = dataTableType;
            this.transactionManager = transactionManager;
            this.connection = transactionManager.Connection;
            this.dataAdapterFactory = new DataAdapterFactory(this.connection);
            this._logManager = logManager;
        }

        public DataTableAdapter(System.Type dataTableType, TransactionManager transactionManager, DatabaseType databaseType, string providerName, ILogManager logManager)
        {
            this.dataTableType = dataTableType;
            this.transactionManager = transactionManager;
            this.connection = transactionManager.Connection;
            this._databaseType = databaseType;
            this._providerName = providerName;
            this.dataAdapterFactory = new DataAdapterFactory(this.connection, this._databaseType, this._providerName);
            this._logManager = logManager;
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="dataTableType">Type of data object.</param>
        /// <param name="definitionName">datatable definition name.</param>
        public DataTableAdapter(System.Type dataTableType, string definitionName)
            : this(dataTableType)
        {
            this.definitionName = definitionName;
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="dataTableType">Type of data object.</param>
        /// <param name="definitionName">datatable definition name.</param>
        /// <param name="connection">database connection.</param>
        public DataTableAdapter(System.Type dataTableType, string definitionName, System.Data.IDbConnection connection)
            : this(dataTableType, connection)
        {
            this.definitionName = definitionName;
        }

        public DataTableAdapter(System.Type dataTableType, string definitionName, System.Data.IDbConnection connection, DatabaseType databaseType, string providerName)
            : this(dataTableType, definitionName, connection)
        {
            this._databaseType = databaseType;
            this._providerName = providerName;
        }

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="dataTableType">Type of data object.</param>
        /// <param name="definitionName">datatable definition name.</param>
        /// <param name="transactionManager">database transaction manager.</param>
        public DataTableAdapter(System.Type dataTableType, string definitionName, TransactionManager transactionManager, ILogManager logManager)
            : this(dataTableType, transactionManager, logManager)
        {
            this.definitionName = definitionName;
        }

        public DataTableAdapter(System.Type dataTableType, string definitionName, TransactionManager transactionManager, DatabaseType databaseType, string providerName, ILogManager logManager)
            : this(dataTableType, definitionName, transactionManager, logManager)
        {
            this._databaseType = databaseType;
            this._providerName = providerName;
        }
        #endregion

        #region Create data adapter 
        /// <summary>
        /// Create DataAdapter.
        /// </summary>
        /// <param name="update">addtion Update Command.</param>
        /// <returns>DataAdapter.</returns>
        public virtual System.Data.IDbDataAdapter CreateDataAdapter(bool update)
        {
            if (this.definitionName != null)
            {
                return this.DataAdapterFactory.CreateDataAdapter(this.dataTableType, this.definitionName, update);
            }
            else
            {
                return this.DataAdapterFactory.CreateDataAdapter(this.dataTableType, update);
            }
        }

        /// <summary>
        /// Create DataAdapter.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="update">addtion Update Command.</param>
        /// <returns>DataAdapter.</returns>
        public virtual System.Data.IDbDataAdapter CreateDataAdapter(string[] columnNames, bool update)
        {
            if (this.definitionName != null)
            {
                return this.DataAdapterFactory.CreateDataAdapter(this.dataTableType, this.definitionName, columnNames, update);
            }
            else
            {
                return this.DataAdapterFactory.CreateDataAdapter(this.dataTableType, columnNames, update);
            }
        }

        /// <summary>
        /// Create DataAdapter.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="update">addtion Update Command.</param>
        /// <returns>DataAdapter.</returns>
        public virtual System.Data.IDbDataAdapter CreateDataAdapter(CommonCommand conditionCommand, bool update)
        {
            if (this.definitionName != null)
            {
                return this.DataAdapterFactory.CreateDataAdapter(this.dataTableType, this.definitionName, conditionCommand, update);
            }
            else
            {
                return this.DataAdapterFactory.CreateDataAdapter(this.dataTableType, conditionCommand, update);
            }
        }

        /// <summary>
        /// Create DataAdapter.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="update">addtion Update Command.</param>
        /// <returns>DataAdapter.</returns>
        public virtual System.Data.IDbDataAdapter CreateDataAdapter(string[] columnNames, CommonCommand conditionCommand, bool update)
        {
            if (this.definitionName != null)
            {
                return this.DataAdapterFactory.CreateDataAdapter(this.dataTableType, this.definitionName, columnNames, conditionCommand, update);
            }
            else
            {
                return this.DataAdapterFactory.CreateDataAdapter(this.dataTableType, columnNames, conditionCommand, update);
            }
        }

        /// <summary>
        /// Create DataAdapter.
        /// </summary>
        /// <param name="update">addtion Update Command.</param>
        /// <param name="checkConcurrency">create check concurrency Update Command.</param>
        /// <returns>DataAdapter.</returns>
        public virtual System.Data.IDbDataAdapter CreateDataAdapter(bool update, bool checkConcurrency)
        {
            if (this.definitionName != null)
            {
                return this.DataAdapterFactory.CreateDataAdapter(this.dataTableType, this.definitionName, update, checkConcurrency);
            }
            else
            {
                return this.DataAdapterFactory.CreateDataAdapter(this.dataTableType, update, checkConcurrency);
            }
        }

        /// <summary>
        /// Create DataAdapter.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="update">addtion Update Command.</param>
        /// <param name="checkConcurrency">create check concurrency Update Command.</param>
        /// <returns>DataAdapter.</returns>
        public virtual System.Data.IDbDataAdapter CreateDataAdapter(string[] columnNames, bool update, bool checkConcurrency)
        {
            if (this.definitionName != null)
            {
                return this.DataAdapterFactory.CreateDataAdapter(this.dataTableType, this.definitionName, columnNames, update, checkConcurrency);
            }
            else
            {
                return this.DataAdapterFactory.CreateDataAdapter(this.dataTableType, columnNames, update, checkConcurrency);
            }
        }

        /// <summary>
        /// Create DataAdapter.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="update">addtion Update Command.</param>
        /// <param name="checkConcurrency">create check concurrency Update Command.</param>
        /// <returns>DataAdapter.</returns>
        public virtual System.Data.IDbDataAdapter CreateDataAdapter(CommonCommand conditionCommand, bool update, bool checkConcurrency)
        {
            if (this.definitionName != null)
            {
                return this.DataAdapterFactory.CreateDataAdapter(this.dataTableType, this.definitionName, conditionCommand, update, checkConcurrency);
            }
            else
            {
                return this.DataAdapterFactory.CreateDataAdapter(this.dataTableType, conditionCommand, update, checkConcurrency);
            }
        }

        /// <summary>
        /// Create DataAdapter.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="update">addtion Update Command.</param>
        /// <param name="checkConcurrency">create check concurrency Update Command.</param>
        /// <returns>DataAdapter.</returns>
        public virtual System.Data.IDbDataAdapter CreateDataAdapter(string[] columnNames, CommonCommand conditionCommand, bool update, bool checkConcurrency)
        {
            if (this.definitionName != null)
            {
                return this.DataAdapterFactory.CreateDataAdapter(this.dataTableType, this.definitionName, columnNames, conditionCommand, update, checkConcurrency);
            }
            else
            {
                return this.DataAdapterFactory.CreateDataAdapter(this.dataTableType, columnNames, conditionCommand, update, checkConcurrency);
            }
        }

        /// <summary>
        /// Create DataAdapter.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <returns>DataAdapter.</returns>
        public virtual System.Data.IDbDataAdapter CreateDataAdapter(object[] primaryKeys)
        {
            if (this.definitionName != null)
            {
                return this.DataAdapterFactory.CreateDataAdapter(this.dataTableType, this.definitionName, primaryKeys);
            }
            else
            {
                return this.DataAdapterFactory.CreateDataAdapter(this.dataTableType, primaryKeys);
            }
        }

        /// <summary>
        /// Create DataAdapter.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <returns>DataAdapter.</returns>
        public virtual System.Data.IDbDataAdapter CreateDataAdapter(object[] primaryKeys, string[] columnNames)
        {
            if (this.definitionName != null)
            {
                return this.DataAdapterFactory.CreateDataAdapter(this.dataTableType, this.definitionName, primaryKeys, columnNames);
            }
            else
            {
                return this.DataAdapterFactory.CreateDataAdapter(this.dataTableType, primaryKeys, columnNames);
            }
        }
        #endregion
        #region Create Command
        /// <summary>
        /// Create a command builder.
        /// </summary>
        /// <returns>Command builder.</returns>
        public virtual RaisingStudio.Data.Common.Builders.CommandBuilder CreateCommandBuilder()
        {
            DatabaseType databaseType = GetDatabaseType();
#if !(PocketPC || Smartphone || WindowsCE)
            if (databaseType == DatabaseType.SHAREPOINT)
            {
                if (this.definitionName != null)
                {
                    return new RaisingStudio.Data.Common.Builders.SharePointCommandBuilder(this.connection, databaseType, this._providerName, this.dataTableType, this.definitionName);
                }
                else
                {
                    return new RaisingStudio.Data.Common.Builders.SharePointCommandBuilder(this.connection, databaseType, this._providerName, this.dataTableType);
                }
            }
            else
            {
#endif
                if (this.definitionName != null)
                {
                    return new RaisingStudio.Data.Common.Builders.CommandBuilder(this.connection, databaseType, this._providerName, this.dataTableType, this.definitionName);
                }
                else
                {
                    return new RaisingStudio.Data.Common.Builders.CommandBuilder(this.connection, databaseType, this._providerName, this.dataTableType);
                }
#if !(PocketPC || Smartphone || WindowsCE)
            }
#endif
        }

        public virtual DatabaseType GetDatabaseType()
        {
            if ((this._databaseType == DatabaseType.OTHER) && (!ProviderManager.Instance.ProviderExists(this._providerName)))
            {
                DatabaseType databaseType = ConnectionFactory.GetDatabaseType(this.connection);
                return databaseType;
            }
            return this._databaseType;
        }
        #endregion
        #region Create datatable 
        /// <summary>
        /// Create Datatable.
        /// </summary>
        /// <returns>Datatable.</returns>
        private System.Data.DataTable CreateDataTableInternal()
        {
            if (this.dataTableType.IsSubclassOf(typeof(System.Data.DataTable)))
            {
                System.Data.DataTable dataTable = System.Activator.CreateInstance(this.dataTableType) as System.Data.DataTable;
                return dataTable;
            }
            else
            {
                System.Data.DataTable dataTable = new System.Data.DataTable();
                System.Xml.XmlElement xmlElement = DefinitionManager.Instance.LoadXmlDocument(this.dataTableType);
                if (xmlElement != null)
                {
                    RaisingStudio.Data.DataTable.InitDataTable(dataTable, this.dataTableType, xmlElement, true);
                }
                else
                {
                    // TODO: use [Attribute] to define Table/Column mapping.
                    RaisingStudio.Data.DataTable.InitDataTable(dataTable, this.dataTableType, xmlElement, true);
                }
                return dataTable;
            }
        }

        protected System.Data.DataTable defaultDataTable;
        /// <summary>
        /// default Datatable.
        /// </summary>
        public System.Data.DataTable DefaultDataTable
        {
            get
            {
                if (this.defaultDataTable == null)
                {
                    this.defaultDataTable = CreateDataTableInternal();
                }
                return this.defaultDataTable;
            }
        }

        /// <summary>
        /// Create Datatable.
        /// </summary>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable CreateDataTable()
        {
            if (this.cloneDataTable)
            {
                return this.DefaultDataTable.Clone();
            }
            else
            {
                return CreateDataTableInternal();
            }
        }


        public System.Data.DataTable CreateDataTable(string[] columns)
        {
            System.Data.DataTable dataTable = new System.Data.DataTable();
            System.Xml.XmlElement xmlElement = DefinitionManager.Instance.LoadXmlDocument(this.dataTableType);
            RaisingStudio.Data.DataTable.InitDataTable(dataTable, this.dataTableType, xmlElement, columns, true);
            return dataTable;
        }

        #endregion

        #region Sets primary key value
        /// <summary>
        /// Sets Command The value of primary key.
        /// </summary>
        /// <param name="values">The value of primary key.</param>
        /// <param name="command">Command.</param>
        protected virtual void SetPrimaryKeyValue(Dictionary<string, object> values, System.Data.IDbCommand command)
        {
            string[] primaryKeyNames = this.CommandBuilder.CommonCommandBuilder.GetPrimaryKeyNames();
            foreach (string columnName in primaryKeyNames)
            {
                System.Data.IDbDataParameter originalMappingParameter = RaisingStudio.Data.Common.Builders.CommandBuilder.GetOriginalMappingParameterByColumn(command.Parameters, columnName);
                if (originalMappingParameter != null)
                {
                    originalMappingParameter.Value = values[columnName];
                }
            }
        }
        /// <summary>
        /// Sets Command The value of primary key.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="values">The value of primary key.</param>
        /// <param name="command">Command.</param>
        protected virtual void SetPrimaryKeyValue(string[] columnNames, object[] values, System.Data.IDbCommand command)
        {
            string[] primaryKeyNames = this.CommandBuilder.CommonCommandBuilder.GetPrimaryKeyNames();
            foreach (string columnName in primaryKeyNames)
            {
                System.Data.IDbDataParameter originalMappingParameter = RaisingStudio.Data.Common.Builders.CommandBuilder.GetOriginalMappingParameterByColumn(command.Parameters, columnName);
                if (originalMappingParameter != null)
                {
                    originalMappingParameter.Value = values[System.Array.IndexOf(columnNames, columnName)];
                }
            }
        }
        /// <summary>
        /// Sets Command The value of primary key.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="command">Command.</param>
        protected virtual void SetPrimaryKeyValue(object[] primaryKeys, System.Data.IDbCommand command)
        {
            string[] primaryKeyNames = this.CommandBuilder.CommonCommandBuilder.GetPrimaryKeyNames();
            for (int i = 0; i < primaryKeyNames.Length; i++)
            {
                string columnName = primaryKeyNames[i];
                System.Data.IDbDataParameter originalMappingParameter = RaisingStudio.Data.Common.Builders.CommandBuilder.GetOriginalMappingParameterByColumn(command.Parameters, columnName);
                if (originalMappingParameter != null)
                {
                    originalMappingParameter.Value = primaryKeys[i];
                }
            }
        }
        #endregion

        #region Transactions
        /// <summary>
        /// Begin Database transaction.
        /// </summary>
        /// <returns>The ID of transaction.</returns>
        public virtual string BeginTransaction()
        {
            return this.transactionManager.BeginTransaction();
        }

        /// <summary>
        /// Begin Database transaction.
        /// </summary>
        /// <param name="isolationLevel">Specifies the isolation level for the transaction.</param>
        /// <returns>The ID of transaction.</returns>
        public virtual string BeginTransaction(System.Data.IsolationLevel isolationLevel)
        {
            return this.transactionManager.BeginTransaction(isolationLevel);
        }

        /// <summary>
        /// Commit Database transaction.
        /// </summary>
        public virtual void CommitTransaction()
        {
            this.transactionManager.CommitTransaction();
        }

        /// <summary>
        /// Commit Database transaction.
        /// </summary>
        /// <param name="transactionID">The ID of transaction.</param>
        public virtual void CommitTransaction(string transactionID)
        {
            this.transactionManager.CommitTransaction(transactionID);
        }

        /// <summary>
        /// Rollback transaction.
        /// </summary>
        public virtual void RollbackTransaction()
        {
            this.transactionManager.RollbackTransaction();
        }

        /// <summary>
        /// Rollback transaction.
        /// </summary>
        /// <param name="transactionID">The ID of transaction.</param>
        public virtual void RollbackTransaction(string transactionID)
        {
            this.transactionManager.RollbackTransaction(transactionID);
        }
        #endregion

        #region protected methods
        #region Base Function 
        /// <summary>
        /// Execute SQL command.
        /// </summary>
        /// <param name="commonCommand">Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The number of rows affected.</returns>
        protected virtual int ExecuteNonQueryCommand(CommonCommand commonCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetMappingCommand(commonCommand);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            int value = RaisingStudio.Data.Common.Database.ExecuteNonQueryCommand(command);
            // set out parameter value.
            CommandConverter.FeedbackParameters(ref commonCommand, command);
            return value;
        }

        /// <summary>
        /// Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.
        /// </summary>
        /// <param name="commonCommand">Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The first column of the first row in the result set, or a null reference (Nothing in Visual Basic) if the result set is empty.</returns>
        protected virtual object ExecuteScalarCommand(CommonCommand commonCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetMappingCommand(commonCommand);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            object value = RaisingStudio.Data.Common.Database.ExecuteScalarCommand(command);
            // set out parameter value.
            CommandConverter.FeedbackParameters(ref commonCommand, command);
            return value;
        }

        /// <summary>
        /// Execute the Command to the Connection and builds a DbDataReader.
        /// </summary>
        /// <param name="commonCommand">Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>A DbDataReader object.</returns>
        protected virtual System.Data.IDataReader ExecuteReaderCommand(CommonCommand commonCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetMappingCommand(commonCommand);
#if !(PocketPC || Smartphone || WindowsCE)
            if (this.DatabaseType == DatabaseType.SHAREPOINT)
            {
                (command as System.Data.SharePoint.SharePointCommand).ListUrl = this.DefaultDataTableMapping.SourceTable;
            }
#endif
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            System.Data.IDataReader dataReader = RaisingStudio.Data.Common.Database.ExecuteReaderCommand(command);
            // set out parameter value.
            CommandConverter.FeedbackParameters(ref commonCommand, command);
            return dataReader;
        }
        #endregion

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>Datatable.</returns>
        protected virtual System.Data.DataTable GetData(System.Data.IDbTransaction transaction)
        {
            System.Data.DataTable dataTable = CreateDataTable();
            Fill(dataTable, transaction);
            return dataTable;
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>Datatable.</returns>
        protected virtual System.Data.DataTable GetData(string[] columnNames, System.Data.IDbTransaction transaction)
        {
            System.Data.DataTable dataTable = CreateDataTable();
            Fill(dataTable, columnNames, transaction);
            return dataTable;
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>Datatable.</returns>
        protected virtual System.Data.DataTable GetData(CommonCommand conditionCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.DataTable dataTable = CreateDataTable();
            Fill(dataTable, conditionCommand, transaction);
            return dataTable;
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>Datatable.</returns>
        protected virtual System.Data.DataTable GetData(string[] columnNames, CommonCommand conditionCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.DataTable dataTable = CreateDataTable();
            Fill(dataTable, columnNames, conditionCommand, transaction);
            return dataTable;
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>Datatable.</returns>
        protected virtual System.Data.DataTable GetData(object[] primaryKeys, System.Data.IDbTransaction transaction)
        {
            System.Data.DataTable dataTable = CreateDataTable();
            Fill(dataTable, primaryKeys, transaction);
            return dataTable;
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>Datatable.</returns>
        protected virtual System.Data.DataTable GetData(object[] primaryKeys, string[] columnNames, System.Data.IDbTransaction transaction)
        {
            System.Data.DataTable dataTable = CreateDataTable();
            Fill(dataTable, primaryKeys, columnNames, transaction);
            return dataTable;
        }

        public virtual int FillDataTableByDataAdapter(System.Data.IDbDataAdapter dataAdapter, System.Data.DataTable dataTable)
        {            
            if (dataAdapter is System.Data.Common.DbDataAdapter)
            {
                WriteLog(dataAdapter);
                return (dataAdapter as System.Data.Common.DbDataAdapter).Fill(dataTable);
            }
            else
            {
                // TODO: exception.
                return -1;
            }
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        protected virtual int Fill(System.Data.DataTable dataTable, System.Data.IDbTransaction transaction)
        {
            this.DefaultDataAdapter.SelectCommand.Transaction = transaction;
            return FillDataTableByDataAdapter(this.DefaultDataAdapter, dataTable);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        protected virtual int Fill(System.Data.DataTable dataTable, string[] columnNames, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateDataAdapter(columnNames, false);
            if (transaction != null)
            {
                dataAdapter.SelectCommand.Transaction = transaction;
            }
            return FillDataTableByDataAdapter(dataAdapter, dataTable);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        protected virtual int Fill(System.Data.DataTable dataTable, CommonCommand conditionCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateDataAdapter(conditionCommand, false);
            if (transaction != null)
            {
                dataAdapter.SelectCommand.Transaction = transaction;
            }
            return FillDataTableByDataAdapter(dataAdapter, dataTable);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        protected virtual int Fill(System.Data.DataTable dataTable, string[] columnNames, CommonCommand conditionCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateDataAdapter(columnNames, conditionCommand, false);
            if (transaction != null)
            {
                dataAdapter.SelectCommand.Transaction = transaction;
            }
            return FillDataTableByDataAdapter(dataAdapter, dataTable);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        protected virtual int Fill(System.Data.DataTable dataTable, object[] primaryKeys, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateDataAdapter(primaryKeys);
            if (transaction != null)
            {
                dataAdapter.SelectCommand.Transaction = transaction;
            }
            return FillDataTableByDataAdapter(dataAdapter, dataTable);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        protected virtual int Fill(System.Data.DataTable dataTable, object[] primaryKeys, string[] columnNames, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateDataAdapter(primaryKeys, columnNames);
            if (transaction != null)
            {
                dataAdapter.SelectCommand.Transaction = transaction;
            }
            return FillDataTableByDataAdapter(dataAdapter, dataTable);
        }


        public virtual int UpdateDataTableByDataAdapter(System.Data.IDbDataAdapter dataAdapter, System.Data.DataTable dataTable)
        {
            if (dataAdapter is System.Data.Common.DbDataAdapter)
            {
                WriteLog(dataAdapter);
                return (dataAdapter as System.Data.Common.DbDataAdapter).Update(dataTable);
            }
            else
            {
                // TODO: exception.
                return -1;
            }
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(System.Data.DataTable dataTable, System.Data.IDbTransaction transaction)
        {
            this.DefaultDataAdapter.DeleteCommand.Transaction = transaction;
            this.DefaultDataAdapter.InsertCommand.Transaction = transaction;
            this.DefaultDataAdapter.UpdateCommand.Transaction = transaction;
            return UpdateDataTableByDataAdapter(this.DefaultDataAdapter, dataTable);
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(System.Data.DataTable dataTable, string[] columnNames, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateDataAdapter(columnNames, true);
            if (transaction != null)
            {
                dataAdapter.DeleteCommand.Transaction = transaction;
                dataAdapter.InsertCommand.Transaction = transaction;
                dataAdapter.UpdateCommand.Transaction = transaction;
            }
            return UpdateDataTableByDataAdapter(dataAdapter, dataTable);
        }


        public static int UpdateDataRowsByDataAdapter(System.Data.IDbDataAdapter dataAdapter, System.Data.DataRow[] dataRows)
        {
            if (dataAdapter is System.Data.Common.DbDataAdapter)
            {
                return (dataAdapter as System.Data.Common.DbDataAdapter).Update(dataRows);
            }
            else
            {
                // TODO: exception.
                return -1;
            }
        }


        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(System.Data.DataRow[] dataRows, System.Data.IDbTransaction transaction)
        {
            this.DefaultDataAdapter.DeleteCommand.Transaction = transaction;
            this.DefaultDataAdapter.InsertCommand.Transaction = transaction;
            this.DefaultDataAdapter.UpdateCommand.Transaction = transaction;
            return UpdateDataRowsByDataAdapter(this.DefaultDataAdapter, dataRows);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(System.Data.DataRow[] dataRows, string[] columnNames, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateDataAdapter(columnNames, true);
            if (transaction != null)
            {
                dataAdapter.DeleteCommand.Transaction = transaction;
                dataAdapter.InsertCommand.Transaction = transaction;
                dataAdapter.UpdateCommand.Transaction = transaction;
            }
            return UpdateDataRowsByDataAdapter(dataAdapter, dataRows);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRow">Datarow.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(System.Data.DataRow dataRow, System.Data.IDbTransaction transaction)
        {
            this.DefaultDataAdapter.DeleteCommand.Transaction = transaction;
            this.DefaultDataAdapter.InsertCommand.Transaction = transaction;
            this.DefaultDataAdapter.UpdateCommand.Transaction = transaction;
            return UpdateDataRowsByDataAdapter(this.DefaultDataAdapter, new System.Data.DataRow[] { dataRow });
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRow">Datarow.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(System.Data.DataRow dataRow, string[] columnNames, System.Data.IDbTransaction transaction)
        {
            return Update(new System.Data.DataRow[] { dataRow }, columnNames, transaction);
        }

        /// <summary>
        /// Delete data.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Delete(object[] primaryKeys, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetDeleteCommand(this.DefaultDataTableMapping, false);
            for (int i = 0; i < command.Parameters.Count; i++)
            {
                SetParameterValue(command.Parameters[i], primaryKeys[i]);
            }
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteNonQueryCommand(command);
        }

        /// <summary>
        /// Delete data.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="originalValues">values.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Delete(string[] columnNames, object[] originalValues, System.Data.IDbTransaction transaction)
        {
            System.Data.Common.DataTableMapping dataTableMapping = this.CommandBuilder.CommonCommandBuilder.GetDataTableMapping(columnNames);
            System.Data.IDbCommand command = this.CommandBuilder.GetDeleteCommand(dataTableMapping, true);
            SetOriginalValue(columnNames, originalValues, command);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteNonQueryCommand(command);
        }

        /// <summary>
        /// Delete data.
        /// </summary>
        /// <param name="originalValues">values.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Delete(Dictionary<string, object> originalValues, System.Data.IDbTransaction transaction)
        {
            string[] columnNames = new string[originalValues.Count];
            originalValues.Keys.CopyTo(columnNames, 0);
            System.Data.Common.DataTableMapping dataTableMapping = this.CommandBuilder.CommonCommandBuilder.GetDataTableMapping(columnNames);
            System.Data.IDbCommand command = this.CommandBuilder.GetDeleteCommand(dataTableMapping, true);
            SetOriginalValue(columnNames, originalValues, command);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteNonQueryCommand(command);
        }

        /// <summary>
        /// Delete the data according the condition.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Delete(CommonCommand conditionCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetDeleteCommand(conditionCommand);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteNonQueryCommand(command);
        }

        /// <summary>
        /// Delete all data.
        /// </summary>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Delete(System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetDeleteCommand();
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteNonQueryCommand(command);
        }

        public void SetParameterValue(object parameter, object value)
        {
            (parameter as System.Data.IDbDataParameter).Value = value;
        }

        /// <summary>
        /// Insert data.
        /// </summary>
        /// <param name="values">values.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Insert(object[] values, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetInsertCommand(this.DefaultDataTableMapping, false);
            int autoIncrementColumnIndex = this.CommandBuilder.CommonCommandBuilder.GetAutoIncrementColumnIndex();
            if (autoIncrementColumnIndex >= 0)
            {
                int j = 0;
                for (int i = 0; i < values.Length; i++)
                {
                    if (i != autoIncrementColumnIndex)
                    {
                        object value = values[i];
                        if (value == null)
                        {
                            SetParameterValue(command.Parameters[j], System.DBNull.Value);
                        }
                        else
                        {
                            SetParameterValue(command.Parameters[j], value);
                        }
                        j++;
                    }
                }
            }
            else
            {
                for (int i = 0; i < command.Parameters.Count; i++)
                {
                    object value = values[i];
                    if (value == null)
                    {
                        SetParameterValue(command.Parameters[i], System.DBNull.Value);
                    }
                    else
                    {
                        SetParameterValue(command.Parameters[i], value);
                    }
                }
            }
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteNonQueryCommand(command);
        }

        /// <summary>
        /// Insert data.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="values">values.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Insert(string[] columnNames, object[] values, System.Data.IDbTransaction transaction)
        {
            System.Data.Common.DataTableMapping dataTableMapping = this.CommandBuilder.CommonCommandBuilder.GetDataTableMapping(columnNames);
            System.Data.IDbCommand command = this.CommandBuilder.GetInsertCommand(dataTableMapping, false);
            SetCurrentValue(columnNames, values, command);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteNonQueryCommand(command);
        }

        /// <summary>
        /// Insert data.
        /// </summary>
        /// <param name="values">values.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Insert(Dictionary<string, object> values, System.Data.IDbTransaction transaction)
        {
            string[] columnNames = new string[values.Count];
            values.Keys.CopyTo(columnNames, 0);
            System.Data.Common.DataTableMapping dataTableMapping = this.CommandBuilder.CommonCommandBuilder.GetDataTableMapping(columnNames);
            System.Data.IDbCommand command = this.CommandBuilder.GetInsertCommand(dataTableMapping, false);
            SetCurrentValue(columnNames, values, command);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteNonQueryCommand(command);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="values">values.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(object[] values, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetUpdateCommand(this.DefaultDataTableMapping, false, false);

            int j = 0;
            int autoIncrementColumnIndex = this.CommandBuilder.CommonCommandBuilder.GetAutoIncrementColumnIndex();
            if (autoIncrementColumnIndex >= 0)
            {
                for (int i = 0; i < values.Length; i++)
                {
                    if (i != autoIncrementColumnIndex)
                    {
                        object value = values[i];
                        if (value == null)
                        {
                            SetParameterValue(command.Parameters[j], System.DBNull.Value);
                        }
                        else
                        {
                            SetParameterValue(command.Parameters[j], value);
                        }
                        j++;
                    }
                }
            }
            else
            {
                for (int i = 0; i < values.Length; i++)
                {
                    object value = values[i];
                    if (value == null)
                    {
                        SetParameterValue(command.Parameters[j], System.DBNull.Value);
                    }
                    else
                    {
                        SetParameterValue(command.Parameters[j], value);
                    }
                    j++;
                }
            }

            int[] primaryKeysIndex = this.CommandBuilder.CommonCommandBuilder.GetPrimaryKeysIndex();
            for (int i = 0; i < primaryKeysIndex.Length; i++)
            {
                SetParameterValue(command.Parameters[j], values[primaryKeysIndex[i]]);
                j++;
            }
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteNonQueryCommand(command);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="values">values.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(string[] columnNames, object[] values, System.Data.IDbTransaction transaction)
        {
            System.Data.Common.DataTableMapping dataTableMapping = this.CommandBuilder.CommonCommandBuilder.GetDataTableMapping(columnNames);
            System.Data.IDbCommand command = this.CommandBuilder.GetUpdateCommand(dataTableMapping, false, false);
            SetCurrentValue(columnNames, values, command);
            SetPrimaryKeyValue(columnNames, values, command);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteNonQueryCommand(command);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="values">values.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(Dictionary<string, object> values, System.Data.IDbTransaction transaction)
        {
            string[] columnNames = new string[values.Count];
            values.Keys.CopyTo(columnNames, 0);
            System.Data.Common.DataTableMapping dataTableMapping = this.CommandBuilder.CommonCommandBuilder.GetDataTableMapping(columnNames);
            System.Data.IDbCommand command = this.CommandBuilder.GetUpdateCommand(dataTableMapping, false, false);
            SetCurrentValue(columnNames, values, command);
            SetPrimaryKeyValue(values, command);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteNonQueryCommand(command);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="values">values.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(object[] primaryKeys, object[] values, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetUpdateCommand(this.DefaultDataTableMapping, false, false);
            int j = 0;
            for (int i = 0; i < values.Length; i++)
            {
                object value = values[i];
                if (value == null)
                {
                    SetParameterValue(command.Parameters[j], System.DBNull.Value);
                }
                else
                {
                    SetParameterValue(command.Parameters[j], value);
                }
                j++;
            }
            for (int i = 0; i < primaryKeys.Length; i++)
            {                
                SetParameterValue(command.Parameters[j], primaryKeys[i]);
                j++;
            }
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteNonQueryCommand(command);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="values">values.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(object[] primaryKeys, string[] columnNames, object[] values, System.Data.IDbTransaction transaction)
        {
            System.Data.Common.DataTableMapping dataTableMapping = this.CommandBuilder.CommonCommandBuilder.GetDataTableMapping(columnNames);
            System.Data.IDbCommand command = this.CommandBuilder.GetUpdateCommand(dataTableMapping, false, false);
            SetCurrentValue(columnNames, values, command);
            SetPrimaryKeyValue(primaryKeys, command);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteNonQueryCommand(command);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="values">values.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(object[] primaryKeys, Dictionary<string, object> values, System.Data.IDbTransaction transaction)
        {
            string[] columnNames = new string[values.Count];
            values.Keys.CopyTo(columnNames, 0);
            System.Data.Common.DataTableMapping dataTableMapping = this.CommandBuilder.CommonCommandBuilder.GetDataTableMapping(columnNames);
            System.Data.IDbCommand command = this.CommandBuilder.GetUpdateCommand(dataTableMapping, false, false);
            SetCurrentValue(columnNames, values, command);
            SetPrimaryKeyValue(primaryKeys, command);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteNonQueryCommand(command);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="originalValues">The original values.</param>
        /// <param name="values">values.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(string[] columnNames, object[] originalValues, object[] values, System.Data.IDbTransaction transaction)
        {
            System.Data.Common.DataTableMapping dataTableMapping = this.CommandBuilder.CommonCommandBuilder.GetDataTableMapping(columnNames);
            System.Data.IDbCommand command = this.CommandBuilder.GetUpdateCommand(dataTableMapping, false, true);
            SetCurrentValue(columnNames, values, command);
            SetOriginalValue(columnNames, originalValues, command);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteNonQueryCommand(command);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="originalValues">The original values.</param>
        /// <param name="values">values.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(Dictionary<string, object> originalValues, Dictionary<string, object> values, System.Data.IDbTransaction transaction)
        {
            string[] columnNames = new string[originalValues.Count];
            originalValues.Keys.CopyTo(columnNames, 0);
            System.Data.Common.DataTableMapping dataTableMapping = this.CommandBuilder.CommonCommandBuilder.GetDataTableMapping(columnNames);
            System.Data.IDbCommand command = this.CommandBuilder.GetUpdateCommand(dataTableMapping, false, true);
            SetCurrentValue(columnNames, values, command);
            SetOriginalValue(columnNames, originalValues, command);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteNonQueryCommand(command);
        }

        /// <summary>
        /// Update the data according the condition.
        /// </summary>
        /// <remarks>
        /// pay attention to the parameter name.
        /// </remarks>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="values">values.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(CommonCommand conditionCommand, object[] values, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetUpdateCommand(this.DefaultDataTableMapping, false, conditionCommand);
            int autoIncrementColumnIndex = this.CommandBuilder.CommonCommandBuilder.GetAutoIncrementColumnIndex();
            if (autoIncrementColumnIndex >= 0)
            {
                int j = 0;
                for (int i = 0; i < values.Length; i++)
                {
                    if (i != autoIncrementColumnIndex)
                    {
                        object value = values[i];
                        if (value == null)
                        {
                            SetParameterValue(command.Parameters[j], System.DBNull.Value);
                        }
                        else
                        {
                            SetParameterValue(command.Parameters[j], value);
                        }
                        j++;
                    }
                }
            }
            else
            {
                for (int i = 0; i < command.Parameters.Count; i++)
                {
                    object value = values[i];
                    if (value == null)
                    {
                        SetParameterValue(command.Parameters[i], System.DBNull.Value);
                    }
                    else
                    {
                        SetParameterValue(command.Parameters[i], value);
                    }
                }
            }
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteNonQueryCommand(command);
        }

        /// <summary>
        /// Update the data according the condition.
        /// </summary>
        /// <remarks>
        /// pay attention to the parameter name.
        /// </remarks>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="values">values.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(CommonCommand conditionCommand, string[] columnNames, object[] values, System.Data.IDbTransaction transaction)
        {
            System.Data.Common.DataTableMapping dataTableMapping = this.CommandBuilder.CommonCommandBuilder.GetDataTableMapping(columnNames);
            System.Data.IDbCommand command = this.CommandBuilder.GetUpdateCommand(dataTableMapping, false, conditionCommand);
            SetCurrentValue(columnNames, values, command);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteNonQueryCommand(command);
        }

        /// <summary>
        /// Update the data according the condition.
        /// </summary>
        /// <remarks>
        /// pay attention to the parameter name.
        /// </remarks>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="values">values.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(CommonCommand conditionCommand, Dictionary<string, object> values, System.Data.IDbTransaction transaction)
        {
            string[] columnNames = new string[values.Count];
            values.Keys.CopyTo(columnNames, 0);
            System.Data.Common.DataTableMapping dataTableMapping = this.CommandBuilder.CommonCommandBuilder.GetDataTableMapping(columnNames);
            System.Data.IDbCommand command = this.CommandBuilder.GetUpdateCommand(dataTableMapping, false, conditionCommand);
            SetCurrentValue(columnNames, values, command);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteNonQueryCommand(command);
        }

        #region Normal Functions
        private System.Data.IDbCommand _defaultDataCountCommand;
        /// <summary>
        /// Gets The count of data rows.
        /// </summary>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of data rows.</returns>
        protected virtual int GetDataCount(System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = null;
            if (CacheDefalutCommand)
            {
                if (_defaultDataCountCommand == null)
                {
                    _defaultDataCountCommand = this.CommandBuilder.GetDataCountCommand();
                }
                command = _defaultDataCountCommand;
            }
            else
            {
                command = this.CommandBuilder.GetDataCountCommand();
            }
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return Convert.ToInt32(RaisingStudio.Data.Common.Database.ExecuteScalarCommand(command));
        }

        /// <summary>
        /// Gets the data row count according the condition.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of data rows.</returns>
        protected virtual int GetDataCount(CommonCommand conditionCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetDataCountCommand(conditionCommand);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return Convert.ToInt32(RaisingStudio.Data.Common.Database.ExecuteScalarCommand(command));
        }
       
        /// <summary>
        /// Gets The count of data rows.
        /// </summary>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of data rows.</returns>
        protected virtual long GetDataLongCount(System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = null;
            if (CacheDefalutCommand)
            {
                if (_defaultDataCountCommand == null)
                {
                    _defaultDataCountCommand = this.CommandBuilder.GetDataCountCommand();
                }
                command = _defaultDataCountCommand;
            }
            else
            {
                command = this.CommandBuilder.GetDataCountCommand();
            }
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return Convert.ToInt64(RaisingStudio.Data.Common.Database.ExecuteScalarCommand(command));
        }

        /// <summary>
        /// Gets the data row count according the condition.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of data rows.</returns>
        protected virtual long GetDataLongCount(CommonCommand conditionCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetDataCountCommand(conditionCommand);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return Convert.ToInt64(RaisingStudio.Data.Common.Database.ExecuteScalarCommand(command));
        }

        /// <summary>
        /// Gets the sum of data.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>the sum of data.</returns>
        protected virtual object GetSumData(string columnName, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetSumDataCommand(columnName);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteScalarCommand(command);
        }

        /// <summary>
        /// Gets the sum of data according the condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>the sum of data.</returns>
        protected virtual object GetSumData(string columnName, CommonCommand conditionCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetSumDataCommand(columnName, conditionCommand);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteScalarCommand(command);
        }

        /// <summary>
        /// Gets the avg of data.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>the avg of data.</returns>
        protected virtual object GetAvgData(string columnName, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetAvgDataCommand(columnName);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteScalarCommand(command);
        }

        /// <summary>
        /// Gets the avg of data according the condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>the avg of data.</returns>
        protected virtual object GetAvgData(string columnName, CommonCommand conditionCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetAvgDataCommand(columnName, conditionCommand);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteScalarCommand(command);
        }

        /// <summary>
        /// Gets the max of data.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>the max of data.</returns>
        protected virtual object GetMaxData(string columnName, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetMaxDataCommand(columnName);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteScalarCommand(command);
        }

        /// <summary>
        /// Get the max of data according condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>the max of data.</returns>
        protected virtual object GetMaxData(string columnName, CommonCommand conditionCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetMaxDataCommand(columnName, conditionCommand);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteScalarCommand(command);
        }

        /// <summary>
        /// Gets the min of data.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>the min of data.</returns>
        protected virtual object GetMinData(string columnName, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetMinDataCommand(columnName);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteScalarCommand(command);
        }

        /// <summary>
        /// Get the min of data according condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>the min of data.</returns>
        protected virtual object GetMinData(string columnName, CommonCommand conditionCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetMinDataCommand(columnName, conditionCommand);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteScalarCommand(command);
        }
        #endregion

        /// <summary>
        /// Check the data by primary key.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>If exists then return true, otherwise return false.</returns>
        protected virtual bool Exists(object[] primaryKeys, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetExistsCommand(this.DefaultDataTableMapping);
            for (int i = 0; i < command.Parameters.Count; i++)
            {
                SetParameterValue(command.Parameters[i], primaryKeys[i]);
            }
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            int count = Convert.ToInt32(RaisingStudio.Data.Common.Database.ExecuteScalarCommand(command));
            return (count > 0) ? true : false;
        }

        /// <summary>
        /// Save data.
        /// </summary>
        /// <param name="values">values.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Save(object[] values, System.Data.IDbTransaction transaction)
        {
            int[] primaryKeysIndex = this.CommandBuilder.CommonCommandBuilder.GetPrimaryKeysIndex();
            object[] primaryKeys = new object[primaryKeysIndex.Length];
            for (int i = 0; i < primaryKeysIndex.Length; i++)
            {
                primaryKeys[i] = values[primaryKeysIndex[i]];
            }
            if (Exists(primaryKeys, transaction))
            {
                return Update(values, transaction);
            }
            else
            {
                return Insert(values, transaction);
            }
        }

        #region 并发冲突及Update 行为
        /// <summary>
        /// Sets data adapter update event handler.
        /// </summary>
        /// <param name="dataAdapter">DataAdapter.</param>
        protected virtual void SetUpRowUpdatedEvent(System.Data.IDbDataAdapter dataAdapter)
        {
            if (dataAdapter is System.Data.SqlClient.SqlDataAdapter)
            {
                (dataAdapter as System.Data.SqlClient.SqlDataAdapter).RowUpdated += new System.Data.SqlClient.SqlRowUpdatedEventHandler(DataTableAdapter_RowUpdated);
            }
#if (PocketPC || Smartphone || WindowsCE)
#else
            else if (dataAdapter is System.Data.OracleClient.OracleDataAdapter)
            {
                (dataAdapter as System.Data.OracleClient.OracleDataAdapter).RowUpdated += new System.Data.OracleClient.OracleRowUpdatedEventHandler(DataTableAdapter_RowUpdated);
            }
            else if (dataAdapter is System.Data.Odbc.OdbcDataAdapter)
            {
                (dataAdapter as System.Data.Odbc.OdbcDataAdapter).RowUpdated += new System.Data.Odbc.OdbcRowUpdatedEventHandler(DataTableAdapter_RowUpdated);
            }
            else if (dataAdapter is System.Data.OleDb.OleDbDataAdapter)
            {
                (dataAdapter as System.Data.OleDb.OleDbDataAdapter).RowUpdated += new System.Data.OleDb.OleDbRowUpdatedEventHandler(DataTableAdapter_RowUpdated);
            }
#endif
            else
            {
                throw (new System.NotSupportedException("Unknown Type."));
            }
        }

        /// <summary>
        /// Update event handler.
        /// </summary>
        /// <param name="sender">event source.</param>
        /// <param name="e">has event data  RowUpdatedEventArgs。</param>
        protected void DataTableAdapter_RowUpdated(object sender, System.Data.Common.RowUpdatedEventArgs e)
        {
            if (e.RecordsAffected == 0)
            {
                if (e.Errors != null)
                {
                    e.Row.RowError = "Update data 行失败。";
                    e.Status = System.Data.UpdateStatus.SkipCurrentRow;
                }
            }
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="dataAdapter">DataAdapter.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, System.Data.IDbDataAdapter dataAdapter, UpdateBehavior updateBehavior, System.Data.IDbTransaction transaction)
        {
            int result = 0;
            if ((updateBehavior == UpdateBehavior.Transactional) && (transaction == null))
            {
                System.Data.ConnectionState previousConnectionState = this.connection.State;
                if ((this.connection.State & System.Data.ConnectionState.Open) != System.Data.ConnectionState.Open)
                {
                    this.connection.Open();
                }
                transaction = this.connection.BeginTransaction();
                try
                {
                    dataAdapter.DeleteCommand.Transaction = transaction;
                    dataAdapter.InsertCommand.Transaction = transaction;
                    dataAdapter.UpdateCommand.Transaction = transaction;
                    result = UpdateDataTableByDataAdapter(dataAdapter, dataTable);
                    transaction.Commit();
                }
                catch //(Exception ex)
                {
                    transaction.Rollback();
                }
                finally
                {
                    if ((previousConnectionState == System.Data.ConnectionState.Closed))
                    {
                        this.connection.Close();
                    }
                }
            }
            else
            {
                dataAdapter.DeleteCommand.Transaction = transaction;
                dataAdapter.InsertCommand.Transaction = transaction;
                dataAdapter.UpdateCommand.Transaction = transaction;

                if (updateBehavior == UpdateBehavior.Continue)
                {
                    SetUpRowUpdatedEvent(dataAdapter);
                    result = UpdateDataTableByDataAdapter(dataAdapter, dataTable);
                }
                else
                {
                    result = UpdateDataTableByDataAdapter(dataAdapter, dataTable);
                }
            }
            return result;
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="dataAdapter">DataAdapter.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(System.Data.DataRow[] dataRows, System.Data.IDbDataAdapter dataAdapter, UpdateBehavior updateBehavior, System.Data.IDbTransaction transaction)
        {
            int result = 0;
            if ((updateBehavior == UpdateBehavior.Transactional) && (transaction == null))
            {
                transaction = this.connection.BeginTransaction();
                try
                {
                    dataAdapter.DeleteCommand.Transaction = transaction;
                    dataAdapter.InsertCommand.Transaction = transaction;
                    dataAdapter.UpdateCommand.Transaction = transaction;
                    result = UpdateDataRowsByDataAdapter(dataAdapter, dataRows);
                    transaction.Commit();
                }
                catch //(Exception ex)
                {
                    transaction.Rollback();
                }
            }
            else if (updateBehavior == UpdateBehavior.Continue)
            {
                if (transaction != null)
                {
                    dataAdapter.DeleteCommand.Transaction = transaction;
                    dataAdapter.InsertCommand.Transaction = transaction;
                    dataAdapter.UpdateCommand.Transaction = transaction;
                }
                SetUpRowUpdatedEvent(dataAdapter);
                result = UpdateDataRowsByDataAdapter(dataAdapter, dataRows);
            }
            else
            {
                result = UpdateDataRowsByDataAdapter(dataAdapter, dataRows);
            }
            return result;
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(System.Data.DataTable dataTable, bool checkConcurrency, UpdateBehavior updateBehavior, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateDataAdapter(true, checkConcurrency);
            return Update(dataTable, dataAdapter, updateBehavior, transaction);
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(System.Data.DataTable dataTable, string[] columnNames, bool checkConcurrency, UpdateBehavior updateBehavior, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateDataAdapter(columnNames, true, checkConcurrency);
            return Update(dataTable, dataAdapter, updateBehavior, transaction);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(System.Data.DataRow[] dataRows, bool checkConcurrency, UpdateBehavior updateBehavior, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateDataAdapter(true, checkConcurrency);
            return Update(dataRows, dataAdapter, updateBehavior, transaction);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(System.Data.DataRow[] dataRows, string[] columnNames, bool checkConcurrency, UpdateBehavior updateBehavior, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateDataAdapter(columnNames, true, checkConcurrency);
            return Update(dataRows, dataAdapter, updateBehavior, transaction);
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(System.Data.DataTable dataTable, UpdateBehavior updateBehavior, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateDataAdapter(true);
            return Update(dataTable, dataAdapter, updateBehavior, transaction);
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(System.Data.DataTable dataTable, string[] columnNames, UpdateBehavior updateBehavior, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateDataAdapter(columnNames, true);
            return Update(dataTable, dataAdapter, updateBehavior, transaction);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(System.Data.DataRow[] dataRows, UpdateBehavior updateBehavior, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateDataAdapter(true);
            return Update(dataRows, dataAdapter, updateBehavior, transaction);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(System.Data.DataRow[] dataRows, string[] columnNames, UpdateBehavior updateBehavior, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateDataAdapter(columnNames, true);
            return Update(dataRows, dataAdapter, updateBehavior, transaction);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(System.Data.DataRow dataRow, bool checkConcurrency, System.Data.IDbTransaction transaction)
        {
            return Update(new System.Data.DataRow[] { dataRow }, checkConcurrency, UpdateBehavior.Standard, transaction);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int Update(System.Data.DataRow dataRow, string[] columnNames, bool checkConcurrency, System.Data.IDbTransaction transaction)
        {
            return Update(new System.Data.DataRow[] { dataRow }, columnNames, checkConcurrency, UpdateBehavior.Standard, transaction);
        }
        #endregion

        #region 自definition adapter 
        /// <summary>
        /// Create DataAdapter.
        /// </summary>
        /// <param name="selectCommand">select Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>DataAdapter.</returns>
        public virtual System.Data.IDbDataAdapter CreateDataAdapter(CommonCommand selectCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = this.DataAdapterFactory.CreateEmptyDataAdapter();
            dataAdapter.SelectCommand = this.CommandBuilder.GetMappingCommand(selectCommand);
            if (transaction != null)
            {
                dataAdapter.SelectCommand.Transaction = transaction;
            }
            (dataAdapter as System.Data.IDataAdapter).TableMappings.Add(this.CommandBuilder.CommonCommandBuilder.GetDataTableMapping());
            return dataAdapter;
        }

        /// <summary>
        /// Create DataAdapter.
        /// </summary>
        /// <param name="selectCommand">select Command.</param>
        /// <param name="insertCommand">Insert command.</param>
        /// <param name="updateCommand">Update command.</param>
        /// <param name="deleteCommand">Delete command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>DataAdapter.</returns>
        public virtual System.Data.IDbDataAdapter CreateDataAdapter(CommonCommand selectCommand, CommonCommand insertCommand, CommonCommand updateCommand, CommonCommand deleteCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = this.DataAdapterFactory.CreateEmptyDataAdapter();
            if (selectCommand != null)
            {
                dataAdapter.SelectCommand = this.CommandBuilder.GetMappingCommand(selectCommand);
                if (transaction != null)
                {
                    dataAdapter.SelectCommand.Transaction = transaction;
                }
            }
            if (insertCommand != null)
            {
                dataAdapter.InsertCommand = this.CommandBuilder.GetMappingCommand(insertCommand);
                if (transaction != null)
                {
                    dataAdapter.InsertCommand.Transaction = transaction;
                }
            }
            if (updateCommand != null)
            {
                dataAdapter.UpdateCommand = this.CommandBuilder.GetMappingCommand(updateCommand);
                if (transaction != null)
                {
                    dataAdapter.UpdateCommand.Transaction = transaction;
                }
            }
            if (deleteCommand != null)
            {
                dataAdapter.DeleteCommand = this.CommandBuilder.GetMappingCommand(deleteCommand);
                if (transaction != null)
                {
                    dataAdapter.DeleteCommand.Transaction = transaction;
                }
            }
            (dataAdapter as System.Data.IDataAdapter).TableMappings.Add(this.CommandBuilder.CommonCommandBuilder.GetDataTableMapping());
            return dataAdapter;
        }


        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="selectCommand">select Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        protected virtual int FillDataTable(System.Data.DataTable dataTable, CommonCommand selectCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateDataAdapter(selectCommand, transaction);
#if !(PocketPC || Smartphone || WindowsCE)
            if (this.DatabaseType == DatabaseType.SHAREPOINT)
            {
                (dataAdapter as System.Data.SharePoint.SharePointDataAdapter).SelectCommand.ListUrl = this.DefaultDataTableMapping.SourceTable;
            }
#endif
            return FillDataTableByDataAdapter(dataAdapter, dataTable);
        }

        protected virtual int FillDataTable(System.Data.DataTable dataTable, CommonCommand selectCommand, int startRecord, int maxRecords, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateDataAdapter(selectCommand, transaction);
            return FillDataTableByDataAdapter(dataAdapter, startRecord, maxRecords, dataTable);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="selectCommand">select Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>Datatable.</returns>
        protected virtual System.Data.DataTable ExecuteDataTable(CommonCommand selectCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.DataTable dataTable = CreateDataTable();
            FillDataTable(dataTable, selectCommand, transaction);
            return dataTable;
        }

        private System.Data.DataTable ExecuteDataTable(CommonCommand selectCommand, int startRecord, int maxRecords, System.Data.IDbTransaction transaction)
        {
            System.Data.DataTable dataTable = CreateDataTable();
            FillDataTable(dataTable, selectCommand, startRecord, maxRecords, transaction);
            return dataTable;
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="insertCommand">Insert command.</param>
        /// <param name="updateCommand">Update command.</param>
        /// <param name="deleteCommand">Delete command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int UpdateDataTable(System.Data.DataTable dataTable, CommonCommand insertCommand, CommonCommand updateCommand, CommonCommand deleteCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateDataAdapter(null, insertCommand, updateCommand, deleteCommand, transaction);
            return UpdateDataTableByDataAdapter(dataAdapter, dataTable);
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="insertCommand">Insert command.</param>
        /// <param name="updateCommand">Update command.</param>
        /// <param name="deleteCommand">Delete command.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        protected virtual int UpdateDataTable(System.Data.DataTable dataTable, CommonCommand insertCommand, CommonCommand updateCommand, CommonCommand deleteCommand, UpdateBehavior updateBehavior, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateDataAdapter(null, insertCommand, updateCommand, deleteCommand, transaction);

            int result = 0;
            if ((updateBehavior == UpdateBehavior.Transactional) && (transaction == null))
            {
                System.Data.ConnectionState previousConnectionState = this.connection.State;
                if ((this.connection.State & System.Data.ConnectionState.Open) != System.Data.ConnectionState.Open)
                {
                    this.connection.Open();
                }
                transaction = this.connection.BeginTransaction();
                try
                {
                    if (dataAdapter.DeleteCommand != null)
                    {
                        dataAdapter.DeleteCommand.Transaction = transaction;
                    }
                    if (dataAdapter.InsertCommand != null)
                    {
                        dataAdapter.InsertCommand.Transaction = transaction;
                    }
                    if (dataAdapter.UpdateCommand != null)
                    {
                        dataAdapter.UpdateCommand.Transaction = transaction;
                    }
                    result = UpdateDataTableByDataAdapter(dataAdapter, dataTable);
                    transaction.Commit();
                }
                catch //(Exception ex)
                {
                    transaction.Rollback();
                }
                finally
                {
                    if ((previousConnectionState == System.Data.ConnectionState.Closed))
                    {
                        this.connection.Close();
                    }
                }
            }
            else
            {
                if (updateBehavior == UpdateBehavior.Continue)
                {
                    SetUpRowUpdatedEvent(dataAdapter);
                    result = UpdateDataTableByDataAdapter(dataAdapter, dataTable);
                }
                else
                {
                    result = UpdateDataTableByDataAdapter(dataAdapter, dataTable);
                }
            }
            return result;
        }
        #endregion

        #region Paging Operation 
        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>Datatable.</returns>
        protected virtual System.Data.DataTable GetData(int startRecord, int maxRecords, System.Data.IDbTransaction transaction)
        {
            System.Data.DataTable dataTable = CreateDataTable();
            Fill(dataTable, startRecord, maxRecords, transaction);
            return dataTable;
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>Datatable.</returns>
        protected virtual System.Data.DataTable GetData(string[] columnNames, int startRecord, int maxRecords, System.Data.IDbTransaction transaction)
        {
            System.Data.DataTable dataTable = CreateDataTable();
            Fill(dataTable, columnNames, startRecord, maxRecords, transaction);
            return dataTable;
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>Datatable.</returns>
        protected virtual System.Data.DataTable GetData(CommonCommand conditionCommand, int startRecord, int maxRecords, System.Data.IDbTransaction transaction)
        {
            System.Data.DataTable dataTable = CreateDataTable();
            Fill(dataTable, conditionCommand, startRecord, maxRecords, transaction);
            return dataTable;
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>Datatable.</returns>
        protected virtual System.Data.DataTable GetData(string[] columnNames, CommonCommand conditionCommand, int startRecord, int maxRecords, System.Data.IDbTransaction transaction)
        {
            System.Data.DataTable dataTable = CreateDataTable();
            Fill(dataTable, columnNames, conditionCommand, startRecord, maxRecords, transaction);
            return dataTable;
        }

        public int FillDataTableByDataAdapter(System.Data.IDbDataAdapter dataAdapter, int startRecord, int maxRecords, System.Data.DataTable dataTable)
        {
            if (dataAdapter is System.Data.Common.DbDataAdapter)
            {
                WriteLog(dataAdapter);
                return (dataAdapter as System.Data.Common.DbDataAdapter).Fill(startRecord, maxRecords, dataTable);
            }
            else
            {
                // TODO: exception.
                return -1;
            }
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        protected virtual int Fill(System.Data.DataTable dataTable, int startRecord, int maxRecords, System.Data.IDbTransaction transaction)
        {
            this.DefaultDataAdapter.SelectCommand.Transaction = transaction;
            return FillDataTableByDataAdapter(this.DefaultDataAdapter, startRecord, maxRecords, dataTable);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        protected virtual int Fill(System.Data.DataTable dataTable, string[] columnNames, int startRecord, int maxRecords, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateDataAdapter(columnNames, false);
            if (transaction != null)
            {
                dataAdapter.SelectCommand.Transaction = transaction;
            }
            return FillDataTableByDataAdapter(dataAdapter, startRecord, maxRecords, dataTable);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        protected virtual int Fill(System.Data.DataTable dataTable, CommonCommand conditionCommand, int startRecord, int maxRecords, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateDataAdapter(conditionCommand, false);
            if (transaction != null)
            {
                dataAdapter.SelectCommand.Transaction = transaction;
            }
            return FillDataTableByDataAdapter(dataAdapter, startRecord, maxRecords, dataTable);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        protected virtual int Fill(System.Data.DataTable dataTable, string[] columnNames, CommonCommand conditionCommand, int startRecord, int maxRecords, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateDataAdapter(columnNames, conditionCommand, false);
            if (transaction != null)
            {
                dataAdapter.SelectCommand.Transaction = transaction;
            }
            return FillDataTableByDataAdapter(dataAdapter, startRecord, maxRecords, dataTable);
        }
        #endregion

        #region View Mode
        /// <summary>
        /// Create DataAdapter.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="update">addtion Update Command.</param>
        /// <returns>DataAdapter.</returns>
        public virtual System.Data.IDbDataAdapter CreateViewDataAdapter(CommonCommand conditionCommand, bool update)
        {
            return this.DataAdapterFactory.CreateViewDataAdapter(this.dataTableType, conditionCommand, update);
        }

        /// <summary>
        /// Create DataAdapter.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="update">addtion Update Command.</param>
        /// <returns>DataAdapter.</returns>
        public virtual System.Data.IDbDataAdapter CreateViewDataAdapter(string[] columnNames, CommonCommand conditionCommand, bool update)
        {
            return this.DataAdapterFactory.CreateViewDataAdapter(this.dataTableType, columnNames, conditionCommand, update);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>Datatable.</returns>
        protected virtual System.Data.DataTable GetViewData(CommonCommand conditionCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.DataTable dataTable = CreateDataTable();
            FillView(dataTable, conditionCommand, transaction);
            return dataTable;
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>Datatable.</returns>
        protected virtual System.Data.DataTable GetViewData(string[] columnNames, CommonCommand conditionCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.DataTable dataTable = CreateDataTable();
            FillView(dataTable, columnNames, conditionCommand, transaction);
            return dataTable;
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        protected virtual int FillView(System.Data.DataTable dataTable, CommonCommand conditionCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateViewDataAdapter(conditionCommand, false);
            if (transaction != null)
            {
                dataAdapter.SelectCommand.Transaction = transaction;
            }
            return FillDataTableByDataAdapter(dataAdapter, dataTable);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        protected virtual int FillView(System.Data.DataTable dataTable, string[] columnNames, CommonCommand conditionCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateViewDataAdapter(columnNames, conditionCommand, false);
            if (transaction != null)
            {
                dataAdapter.SelectCommand.Transaction = transaction;
            }
            return FillDataTableByDataAdapter(dataAdapter, dataTable);
        }

        #region Normal Functions
        /// <summary>
        /// Gets the data row count according the condition.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The count of data rows.</returns>
        protected virtual int GetViewDataCount(CommonCommand conditionCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetViewDataCountCommand(conditionCommand);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return Convert.ToInt32(RaisingStudio.Data.Common.Database.ExecuteScalarCommand(command));
        }

        /// <summary>
        /// Gets the sum of data according the condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>the sum of data.</returns>
        protected virtual object GetViewSumData(string columnName, CommonCommand conditionCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetViewSumDataCommand(columnName, conditionCommand);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteScalarCommand(command);
        }

        /// <summary>
        /// Gets the avg of data according the condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>the avg of data.</returns>
        protected virtual object GetViewAvgData(string columnName, CommonCommand conditionCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetViewAvgDataCommand(columnName, conditionCommand);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteScalarCommand(command);
        }

        /// <summary>
        /// Get the max of data according condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>the max of data.</returns>
        protected virtual object GetViewMaxData(string columnName, CommonCommand conditionCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetViewMaxDataCommand(columnName, conditionCommand);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteScalarCommand(command);
        }

        /// <summary>
        /// Get the min of data according condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>the min of data.</returns>
        protected virtual object GetViewMinData(string columnName, CommonCommand conditionCommand, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbCommand command = this.CommandBuilder.GetViewMinDataCommand(columnName, conditionCommand);
            if (transaction != null)
            {
                command.Transaction = transaction;
            }
            WriteLog(command);
            return RaisingStudio.Data.Common.Database.ExecuteScalarCommand(command);
        }
        #endregion

        #region Paging Operation 
        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>Datatable.</returns>
        protected virtual System.Data.DataTable GetViewData(CommonCommand conditionCommand, int startRecord, int maxRecords, System.Data.IDbTransaction transaction)
        {
            System.Data.DataTable dataTable = CreateDataTable();
            FillView(dataTable, conditionCommand, startRecord, maxRecords, transaction);
            return dataTable;
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>Datatable.</returns>
        protected virtual System.Data.DataTable GetViewData(string[] columnNames, CommonCommand conditionCommand, int startRecord, int maxRecords, System.Data.IDbTransaction transaction)
        {
            System.Data.DataTable dataTable = CreateDataTable();
            FillView(dataTable, columnNames, conditionCommand, startRecord, maxRecords, transaction);
            return dataTable;
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        protected virtual int FillView(System.Data.DataTable dataTable, CommonCommand conditionCommand, int startRecord, int maxRecords, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateViewDataAdapter(conditionCommand, false);
            if (transaction != null)
            {
                dataAdapter.SelectCommand.Transaction = transaction;
            }
            return FillDataTableByDataAdapter(dataAdapter, startRecord, maxRecords, dataTable);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transaction">Database transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        protected virtual int FillView(System.Data.DataTable dataTable, string[] columnNames, CommonCommand conditionCommand, int startRecord, int maxRecords, System.Data.IDbTransaction transaction)
        {
            System.Data.IDbDataAdapter dataAdapter = CreateViewDataAdapter(columnNames, conditionCommand, false);
            if (transaction != null)
            {
                dataAdapter.SelectCommand.Transaction = transaction;
            }
            return FillDataTableByDataAdapter(dataAdapter, startRecord, maxRecords, dataTable);
        }
        #endregion
        #endregion
        #endregion

        #region Common Methods
        #region Base Function 
        /// <summary>
        /// Execute SQL command.
        /// </summary>
        /// <param name="commonCommand">Command.</param>
        /// <returns>The number of rows affected.</returns>
        public virtual int ExecuteNonQueryCommand(CommonCommand commonCommand)
        {
            return ExecuteNonQueryCommand(commonCommand, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.
        /// </summary>
        /// <param name="commonCommand">Command.</param>
        /// <returns>The first column of the first row in the result set, or a null reference (Nothing in Visual Basic) if the result set is empty.</returns>
        public virtual object ExecuteScalarCommand(CommonCommand commonCommand)
        {
            return ExecuteScalarCommand(commonCommand, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Execute the Command to the Connection and builds a DbDataReader.
        /// </summary>
        /// <param name="commonCommand">Command.</param>
        /// <returns>A DbDataReader object.</returns>
        public virtual System.Data.IDataReader ExecuteReaderCommand(CommonCommand commonCommand)
        {
            return ExecuteReaderCommand(commonCommand, this.TransactionManager.DefaultTransaction);
        }
        #endregion

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable)
        {
            return Fill(dataTable, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, string[] columnNames)
        {
            return Fill(dataTable, columnNames, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, CommonCommand conditionCommand)
        {
            return Fill(dataTable, conditionCommand, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, string[] columnNames, CommonCommand conditionCommand)
        {
            return Fill(dataTable, columnNames, conditionCommand, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, object[] primaryKeys)
        {
            return Fill(dataTable, primaryKeys, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, object[] primaryKeys, string[] columnNames)
        {
            return Fill(dataTable, primaryKeys, columnNames, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData()
        {
            return GetData(this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(string[] columnNames)
        {
            return GetData(columnNames, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(CommonCommand conditionCommand)
        {
            return GetData(conditionCommand, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(string[] columnNames, CommonCommand conditionCommand)
        {
            return GetData(columnNames, conditionCommand, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(object[] primaryKeys)
        {
            return GetData(primaryKeys, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(object[] primaryKeys, string[] columnNames)
        {
            return GetData(primaryKeys, columnNames, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable)
        {
            return Update(dataTable, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, string[] columnNames)
        {
            return Update(dataTable, columnNames, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows)
        {
            return Update(dataRows, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows, string[] columnNames)
        {
            return Update(dataRows, columnNames, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRow">Datarow.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow dataRow)
        {
            return Update(dataRow, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRow">Datarow.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow dataRow, string[] columnNames)
        {
            return Update(dataRow, columnNames, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Delete data.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Delete(object[] primaryKeys)
        {
            return Delete(primaryKeys, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Delete data.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="originalValues">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Delete(string[] columnNames, object[] originalValues)
        {
            return Delete(columnNames, originalValues, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Delete data.
        /// </summary>
        /// <param name="originalValues">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Delete(Dictionary<string, object> originalValues)
        {
            return Delete(originalValues, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Delete the data according the condition.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Delete(CommonCommand conditionCommand)
        {
            return Delete(conditionCommand, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Delete all data.
        /// </summary>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Delete()
        {
            return Delete(this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Insert data.
        /// </summary>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Insert(object[] values)
        {
            return Insert(values, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Insert data.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Insert(string[] columnNames, object[] values)
        {
            return Insert(columnNames, values, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Insert data.
        /// </summary>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Insert(Dictionary<string, object> values)
        {
            return Insert(values, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(object[] values)
        {
            return Update(values, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(string[] columnNames, object[] values)
        {
            return Update(columnNames, values, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(Dictionary<string, object> values)
        {
            return Update(values, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(object[] primaryKeys, object[] values)
        {
            return Update(primaryKeys, values, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(object[] primaryKeys, string[] columnNames, object[] values)
        {
            return Update(primaryKeys, columnNames, values, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(object[] primaryKeys, Dictionary<string, object> values)
        {
            return Update(primaryKeys, values, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="originalValues">The original values.</param>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(string[] columnNames, object[] originalValues, object[] values)
        {
            return Update(columnNames, originalValues, values, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="originalValues">The original values.</param>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(Dictionary<string, object> originalValues, Dictionary<string, object> values)
        {
            return Update(originalValues, values, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update the data according the condition.
        /// </summary>
        /// <remarks>
        /// pay attention to the parameter name.
        /// </remarks>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(CommonCommand conditionCommand, object[] values)
        {
            return Update(conditionCommand, values, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update the data according the condition.
        /// </summary>
        /// <remarks>
        /// pay attention to the parameter name.
        /// </remarks>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(CommonCommand conditionCommand, string[] columnNames, object[] values)
        {
            return Update(conditionCommand, columnNames, values, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update the data according the condition.
        /// </summary>
        /// <remarks>
        /// pay attention to the parameter name.
        /// </remarks>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(CommonCommand conditionCommand, Dictionary<string, object> values)
        {
            return Update(conditionCommand, values, this.TransactionManager.DefaultTransaction);
        }

        #region Normal Functions
        /// <summary>
        /// Gets The count of data rows.
        /// </summary>
        /// <returns>The count of data rows.</returns>
        public virtual int GetDataCount()
        {
            return GetDataCount(this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets the data row count according the condition.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>The count of data rows.</returns>
        public virtual int GetDataCount(CommonCommand conditionCommand)
        {
            return GetDataCount(conditionCommand, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets The count of data rows.
        /// </summary>
        /// <returns>The count of data rows.</returns>
        public virtual long GetDataLongCount()
        {
            return GetDataLongCount(this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets the data row count according the condition.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>The count of data rows.</returns>
        public virtual long GetDataLongCount(CommonCommand conditionCommand)
        {
            return GetDataLongCount(conditionCommand, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets the sum of data.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <returns>the sum of data.</returns>
        public virtual object GetSumData(string columnName)
        {
            return GetSumData(columnName, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets the sum of data according the condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>the sum of data.</returns>
        public virtual object GetSumData(string columnName, CommonCommand conditionCommand)
        {
            return GetSumData(columnName, conditionCommand, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets the avg of data.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <returns>the avg of data.</returns>
        public virtual object GetAvgData(string columnName)
        {
            return GetAvgData(columnName, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets the avg of data according the condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>the avg of data.</returns>
        public virtual object GetAvgData(string columnName, CommonCommand conditionCommand)
        {
            return GetAvgData(columnName, conditionCommand, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets the max of data.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <returns>the max of data.</returns>
        public virtual object GetMaxData(string columnName)
        {
            return GetMaxData(columnName, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Get the max of data according condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>the max of data.</returns>
        public virtual object GetMaxData(string columnName, CommonCommand conditionCommand)
        {
            return GetMaxData(columnName, conditionCommand, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets the min of data.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <returns>the min of data.</returns>
        public virtual object GetMinData(string columnName)
        {
            return GetMinData(columnName, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Get the min of data according condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>the min of data.</returns>
        public virtual object GetMinData(string columnName, CommonCommand conditionCommand)
        {
            return GetMinData(columnName, conditionCommand, this.TransactionManager.DefaultTransaction);
        }
        #endregion

        /// <summary>
        /// Check the data by primary key.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <returns>If exists then return true, otherwise return false.</returns>
        public virtual bool Exists(object[] primaryKeys)
        {
            return Exists(primaryKeys, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Save data.
        /// </summary>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Save(object[] values)
        {
            return Save(values, this.TransactionManager.DefaultTransaction);
        }

        #region 并发冲突及Update 行为
        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, bool checkConcurrency)
        {
            return Update(dataTable, checkConcurrency, UpdateBehavior.Standard, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, string[] columnNames, bool checkConcurrency)
        {
            return Update(dataTable, columnNames, checkConcurrency, UpdateBehavior.Standard, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows, bool checkConcurrency)
        {
            return Update(dataRows, checkConcurrency, UpdateBehavior.Standard, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows, string[] columnNames, bool checkConcurrency)
        {
            return Update(dataRows, columnNames, checkConcurrency, UpdateBehavior.Standard, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRow">Datarow.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow dataRow, bool checkConcurrency)
        {
            return Update(dataRow, checkConcurrency, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRow">Datarow.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow dataRow, string[] columnNames, bool checkConcurrency)
        {
            return Update(dataRow, columnNames, checkConcurrency, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, UpdateBehavior updateBehavior)
        {
            return Update(dataTable, updateBehavior, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, string[] columnNames, UpdateBehavior updateBehavior)
        {
            return Update(dataTable, columnNames, updateBehavior, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows, UpdateBehavior updateBehavior)
        {
            return Update(dataRows, updateBehavior, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows, string[] columnNames, UpdateBehavior updateBehavior)
        {
            return Update(dataRows, columnNames, updateBehavior, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, bool checkConcurrency, UpdateBehavior updateBehavior)
        {
            return Update(dataTable, updateBehavior, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, string[] columnNames, bool checkConcurrency, UpdateBehavior updateBehavior)
        {
            return Update(dataTable, columnNames, checkConcurrency, updateBehavior, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows, bool checkConcurrency, UpdateBehavior updateBehavior)
        {
            return Update(dataRows, checkConcurrency, updateBehavior, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows, string[] columnNames, bool checkConcurrency, UpdateBehavior updateBehavior)
        {
            return Update(dataRows, columnNames, checkConcurrency, updateBehavior, this.TransactionManager.DefaultTransaction);
        }
        #endregion

        #region 自definition adapter 
        /// <summary>
        /// Create DataAdapter.
        /// </summary>
        /// <param name="selectCommand">Condition Command.</param>
        /// <returns>DataAdapter.</returns>
        public virtual System.Data.IDbDataAdapter CreateDataAdapter(CommonCommand selectCommand)
        {
            return CreateDataAdapter(selectCommand, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Create DataAdapter.
        /// </summary>
        /// <param name="selectCommand">Condition Command.</param>
        /// <param name="insertCommand">Insert command.</param>
        /// <param name="updateCommand">Update command.</param>
        /// <param name="deleteCommand">Delete command.</param>
        /// <returns>DataAdapter.</returns>
        public virtual System.Data.IDbDataAdapter CreateDataAdapter(CommonCommand selectCommand, CommonCommand insertCommand, CommonCommand updateCommand, CommonCommand deleteCommand)
        {
            return CreateDataAdapter(selectCommand, insertCommand, updateCommand, deleteCommand, this.TransactionManager.DefaultTransaction);
        }


        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="selectCommand">select Command.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int FillDataTable(System.Data.DataTable dataTable, CommonCommand selectCommand)
        {
            return FillDataTable(dataTable, selectCommand, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="selectCommand">select Command.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable ExecuteDataTable(CommonCommand selectCommand)
        {
            return ExecuteDataTable(selectCommand, this.TransactionManager.DefaultTransaction);
        }

        public System.Data.DataTable ExecuteDataTable(CommonCommand selectCommand, int startRecord, int maxRecords)
        {
            return ExecuteDataTable(selectCommand, startRecord, maxRecords, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="insertCommand">Insert command.</param>
        /// <param name="updateCommand">Update command.</param>
        /// <param name="deleteCommand">Delete command.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int UpdateDataTable(System.Data.DataTable dataTable, CommonCommand insertCommand, CommonCommand updateCommand, CommonCommand deleteCommand)
        {
            return UpdateDataTable(dataTable, insertCommand, updateCommand, deleteCommand, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="insertCommand">Insert command.</param>
        /// <param name="updateCommand">Update command.</param>
        /// <param name="deleteCommand">Delete command.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int UpdateDataTable(System.Data.DataTable dataTable, CommonCommand insertCommand, CommonCommand updateCommand, CommonCommand deleteCommand, UpdateBehavior updateBehavior)
        {
            return UpdateDataTable(dataTable, insertCommand, updateCommand, deleteCommand, updateBehavior, this.TransactionManager.DefaultTransaction);
        }
        #endregion

        #region Paging Operation 
        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, int startRecord, int maxRecords)
        {
            return Fill(dataTable, startRecord, maxRecords, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, string[] columnNames, int startRecord, int maxRecords)
        {
            return Fill(dataTable, columnNames, startRecord, maxRecords, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, CommonCommand conditionCommand, int startRecord, int maxRecords)
        {
            return Fill(dataTable, conditionCommand, startRecord, maxRecords, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, string[] columnNames, CommonCommand conditionCommand, int startRecord, int maxRecords)
        {
            return Fill(dataTable, columnNames, startRecord, maxRecords, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(int startRecord, int maxRecords)
        {
            return GetData(startRecord, maxRecords, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(string[] columnNames, int startRecord, int maxRecords)
        {
            return GetData(columnNames, startRecord, maxRecords, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(CommonCommand conditionCommand, int startRecord, int maxRecords)
        {
            return GetData(conditionCommand, startRecord, maxRecords, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(string[] columnNames, CommonCommand conditionCommand, int startRecord, int maxRecords)
        {
            return GetData(columnNames, conditionCommand, startRecord, maxRecords, this.TransactionManager.DefaultTransaction);
        }
        #endregion

        #region View Mode
        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetViewData(CommonCommand conditionCommand)
        {
            return this.GetViewData(conditionCommand, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetViewData(string[] columnNames, CommonCommand conditionCommand)
        {
            return this.GetViewData(columnNames, conditionCommand, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int FillView(System.Data.DataTable dataTable, CommonCommand conditionCommand)
        {
            return this.FillView(dataTable, conditionCommand, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int FillView(System.Data.DataTable dataTable, string[] columnNames, CommonCommand conditionCommand)
        {
            return this.FillView(dataTable, columnNames, conditionCommand, this.TransactionManager.DefaultTransaction);
        }

        #region Normal Functions
        /// <summary>
        /// Gets the data row count according the condition.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>The count of data rows.</returns>
        public virtual int GetViewDataCount(CommonCommand conditionCommand)
        {
            return this.GetViewDataCount(conditionCommand, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets the sum of data according the condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>the sum of data.</returns>
        public virtual object GetViewSumData(string columnName, CommonCommand conditionCommand)
        {
            return this.GetViewSumData(columnName, conditionCommand, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets the avg of data according the condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>the avg of data.</returns>
        public virtual object GetViewAvgData(string columnName, CommonCommand conditionCommand)
        {
            return this.GetViewAvgData(columnName, conditionCommand, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Get the max of data according condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>the max of data.</returns>
        public virtual object GetViewMaxData(string columnName, CommonCommand conditionCommand)
        {
            return this.GetViewMaxData(columnName, conditionCommand, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Get the min of data according condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <returns>the min of data.</returns>
        public virtual object GetViewMinData(string columnName, CommonCommand conditionCommand)
        {
            return this.GetViewMinData(columnName, conditionCommand, this.TransactionManager.DefaultTransaction);
        }
        #endregion

        #region Paging Operation 
        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetViewData(CommonCommand conditionCommand, int startRecord, int maxRecords)
        {
            return this.GetViewData(conditionCommand, startRecord, maxRecords, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetViewData(string[] columnNames, CommonCommand conditionCommand, int startRecord, int maxRecords)
        {
            return this.GetViewData(columnNames, conditionCommand, startRecord, maxRecords, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int FillView(System.Data.DataTable dataTable, CommonCommand conditionCommand, int startRecord, int maxRecords)
        {
            return this.FillView(dataTable, conditionCommand, startRecord, maxRecords, this.TransactionManager.DefaultTransaction);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int FillView(System.Data.DataTable dataTable, string[] columnNames, CommonCommand conditionCommand, int startRecord, int maxRecords)
        {
            return this.FillView(dataTable, columnNames, conditionCommand, startRecord, maxRecords, this.TransactionManager.DefaultTransaction);
        }
        #endregion
        #endregion
        #endregion
        #region Transaction
        #region Base Function 
        /// <summary>
        /// Execute SQL command.
        /// </summary>
        /// <param name="commonCommand">Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows affected.</returns>
        public virtual int ExecuteNonQueryCommand(CommonCommand commonCommand, string transactionID)
        {
            return ExecuteNonQueryCommand(commonCommand, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Executes the query, and returns the first column of the first row in the result set returned by the query. Additional columns or rows are ignored.
        /// </summary>
        /// <param name="commonCommand">Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The first column of the first row in the result set, or a null reference (Nothing in Visual Basic) if the result set is empty.</returns>
        public virtual object ExecuteScalarCommand(CommonCommand commonCommand, string transactionID)
        {
            return ExecuteScalarCommand(commonCommand, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Execute the Command to the Connection and builds a DbDataReader.
        /// </summary>
        /// <param name="commonCommand">Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>A DbDataReader object.</returns>
        public virtual System.Data.IDataReader ExecuteReaderCommand(CommonCommand commonCommand, string transactionID)
        {
            return ExecuteReaderCommand(commonCommand, this.TransactionManager.GetTransaction(transactionID));
        }
        #endregion

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, string transactionID)
        {
            return Fill(dataTable, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, string[] columnNames, string transactionID)
        {
            return Fill(dataTable, columnNames, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, CommonCommand conditionCommand, string transactionID)
        {
            return Fill(dataTable, conditionCommand, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, string[] columnNames, CommonCommand conditionCommand, string transactionID)
        {
            return Fill(dataTable, columnNames, conditionCommand, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, object[] primaryKeys, string transactionID)
        {
            return Fill(dataTable, primaryKeys, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, object[] primaryKeys, string[] columnNames, string transactionID)
        {
            return Fill(dataTable, primaryKeys, columnNames, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(string transactionID)
        {
            return GetData(this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(string[] columnNames, string transactionID)
        {
            return GetData(columnNames, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(CommonCommand conditionCommand, string transactionID)
        {
            return GetData(conditionCommand, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(string[] columnNames, CommonCommand conditionCommand, string transactionID)
        {
            return GetData(columnNames, conditionCommand, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(object[] primaryKeys, string transactionID)
        {
            return GetData(primaryKeys, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(object[] primaryKeys, string[] columnNames, string transactionID)
        {
            return GetData(primaryKeys, columnNames, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, string transactionID)
        {
            return Update(dataTable, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, string[] columnNames, string transactionID)
        {
            return Update(dataTable, columnNames, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows, string transactionID)
        {
            return Update(dataRows, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows, string[] columnNames, string transactionID)
        {
            return Update(dataRows, columnNames, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRow">Datarow.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow dataRow, string transactionID)
        {
            return Update(dataRow, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRow">Datarow.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow dataRow, string[] columnNames, string transactionID)
        {
            return Update(dataRow, columnNames, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Delete data.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Delete(object[] primaryKeys, string transactionID)
        {
            return Delete(primaryKeys, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Delete data.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="originalValues">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Delete(string[] columnNames, object[] originalValues, string transactionID)
        {
            return Delete(columnNames, originalValues, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Delete data.
        /// </summary>
        /// <param name="originalValues">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Delete(Dictionary<string, object> originalValues, string transactionID)
        {
            return Delete(originalValues, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Delete the data according the condition.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Delete(CommonCommand conditionCommand, string transactionID)
        {
            return Delete(conditionCommand, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Delete all data.
        /// </summary>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Delete(string transactionID)
        {
            return Delete(this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Insert data.
        /// </summary>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Insert(object[] values, string transactionID)
        {
            return Insert(values, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Insert data.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Insert(string[] columnNames, object[] values, string transactionID)
        {
            return Insert(columnNames, values, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Insert data.
        /// </summary>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Insert(Dictionary<string, object> values, string transactionID)
        {
            return Insert(values, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(object[] values, string transactionID)
        {
            return Update(values, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(string[] columnNames, object[] values, string transactionID)
        {
            return Update(columnNames, values, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(Dictionary<string, object> values, string transactionID)
        {
            return Update(values, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(object[] primaryKeys, object[] values, string transactionID)
        {
            return Update(primaryKeys, values, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(object[] primaryKeys, string[] columnNames, object[] values, string transactionID)
        {
            return Update(primaryKeys, columnNames, values, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(object[] primaryKeys, Dictionary<string, object> values, string transactionID)
        {
            return Update(primaryKeys, values, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="originalValues">The original values.</param>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(string[] columnNames, object[] originalValues, object[] values, string transactionID)
        {
            return Update(columnNames, originalValues, values, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="originalValues">The original values.</param>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(Dictionary<string, object> originalValues, Dictionary<string, object> values, string transactionID)
        {
            return Update(originalValues, values, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update the data according the condition.
        /// </summary>
        /// <remarks>
        /// pay attention to the parameter name.
        /// </remarks>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(CommonCommand conditionCommand, object[] values, string transactionID)
        {
            return Update(conditionCommand, values, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update the data according the condition.
        /// </summary>
        /// <remarks>
        /// pay attention to the parameter name.
        /// </remarks>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(CommonCommand conditionCommand, string[] columnNames, object[] values, string transactionID)
        {
            return Update(conditionCommand, columnNames, values, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update the data according the condition.
        /// </summary>
        /// <remarks>
        /// pay attention to the parameter name.
        /// </remarks>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(CommonCommand conditionCommand, Dictionary<string, object> values, string transactionID)
        {
            return Update(conditionCommand, values, this.TransactionManager.GetTransaction(transactionID));
        }

        #region Normal Functions
        /// <summary>
        /// Gets The count of data rows.
        /// </summary>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of data rows.</returns>
        public virtual int GetDataCount(string transactionID)
        {
            return GetDataCount(this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Gets the data row count according the condition.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of data rows.</returns>
        public virtual int GetDataCount(CommonCommand conditionCommand, string transactionID)
        {
            return GetDataCount(conditionCommand, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Gets the sum of data.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the sum of data.</returns>
        public virtual object GetSumData(string columnName, string transactionID)
        {
            return GetSumData(columnName, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Gets the sum of data according the condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the sum of data.</returns>
        public virtual object GetSumData(string columnName, CommonCommand conditionCommand, string transactionID)
        {
            return GetSumData(columnName, conditionCommand, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Gets the avg of data.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the avg of data.</returns>
        public virtual object GetAvgData(string columnName, string transactionID)
        {
            return GetAvgData(columnName, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Gets the avg of data according the condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the avg of data.</returns>
        public virtual object GetAvgData(string columnName, CommonCommand conditionCommand, string transactionID)
        {
            return GetAvgData(columnName, conditionCommand, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Gets the max of data.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the max of data.</returns>
        public virtual object GetMaxData(string columnName, string transactionID)
        {
            return GetMaxData(columnName, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Get the max of data according condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the max of data.</returns>
        public virtual object GetMaxData(string columnName, CommonCommand conditionCommand, string transactionID)
        {
            return GetMaxData(columnName, conditionCommand, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Gets the min of data.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the min of data.</returns>
        public virtual object GetMinData(string columnName, string transactionID)
        {
            return GetMinData(columnName, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Get the min of data according condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the min of data.</returns>
        public virtual object GetMinData(string columnName, CommonCommand conditionCommand, string transactionID)
        {
            return GetMinData(columnName, conditionCommand, this.TransactionManager.GetTransaction(transactionID));
        }
        #endregion

        /// <summary>
        /// Check the data by primary key.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>If exists then return true, otherwise return false.</returns>
        public virtual bool Exists(object[] primaryKeys, string transactionID)
        {
            return Exists(primaryKeys, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Save data.
        /// </summary>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Save(object[] values, string transactionID)
        {
            return Save(values, this.TransactionManager.GetTransaction(transactionID));
        }

        #region 并发冲突及Update 行为
        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, bool checkConcurrency, string transactionID)
        {
            return Update(dataTable, checkConcurrency, UpdateBehavior.Standard, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, string[] columnNames, bool checkConcurrency, string transactionID)
        {
            return Update(dataTable, columnNames, checkConcurrency, UpdateBehavior.Standard, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows, bool checkConcurrency, string transactionID)
        {
            return Update(dataRows, checkConcurrency, UpdateBehavior.Standard, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows, string[] columnNames, bool checkConcurrency, string transactionID)
        {
            return Update(dataRows, columnNames, checkConcurrency, UpdateBehavior.Standard, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRow">Datarow.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow dataRow, bool checkConcurrency, string transactionID)
        {
            return Update(dataRow, checkConcurrency, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRow">Datarow.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow dataRow, string[] columnNames, bool checkConcurrency, string transactionID)
        {
            return Update(dataRow, columnNames, checkConcurrency, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, UpdateBehavior updateBehavior, string transactionID)
        {
            return Update(dataTable, updateBehavior, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, string[] columnNames, UpdateBehavior updateBehavior, string transactionID)
        {
            return Update(dataTable, columnNames, updateBehavior, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows, UpdateBehavior updateBehavior, string transactionID)
        {
            return Update(dataRows, updateBehavior, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows, string[] columnNames, UpdateBehavior updateBehavior, string transactionID)
        {
            return Update(dataRows, columnNames, updateBehavior, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, bool checkConcurrency, UpdateBehavior updateBehavior, string transactionID)
        {
            return Update(dataTable, updateBehavior, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, string[] columnNames, bool checkConcurrency, UpdateBehavior updateBehavior, string transactionID)
        {
            return Update(dataTable, columnNames, checkConcurrency, updateBehavior, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows, bool checkConcurrency, UpdateBehavior updateBehavior, string transactionID)
        {
            return Update(dataRows, checkConcurrency, updateBehavior, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows, string[] columnNames, bool checkConcurrency, UpdateBehavior updateBehavior, string transactionID)
        {
            return Update(dataRows, columnNames, checkConcurrency, updateBehavior, this.TransactionManager.GetTransaction(transactionID));
        }
        #endregion

        #region 自definition adapter 
        /// <summary>
        /// Create DataAdapter.
        /// </summary>
        /// <param name="selectCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>DataAdapter.</returns>
        public virtual System.Data.IDbDataAdapter CreateDataAdapter(CommonCommand selectCommand, string transactionID)
        {
            return CreateDataAdapter(selectCommand, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Create DataAdapter.
        /// </summary>
        /// <param name="selectCommand">Condition Command.</param>
        /// <param name="insertCommand">Insert command.</param>
        /// <param name="updateCommand">Update command.</param>
        /// <param name="deleteCommand">Delete command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>DataAdapter.</returns>
        public virtual System.Data.IDbDataAdapter CreateDataAdapter(CommonCommand selectCommand, CommonCommand insertCommand, CommonCommand updateCommand, CommonCommand deleteCommand, string transactionID)
        {
            return CreateDataAdapter(selectCommand, insertCommand, updateCommand, deleteCommand, this.TransactionManager.GetTransaction(transactionID));
        }


        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="selectCommand">select Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int FillDataTable(System.Data.DataTable dataTable, CommonCommand selectCommand, string transactionID)
        {
            return FillDataTable(dataTable, selectCommand, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="selectCommand">select Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable ExecuteDataTable(CommonCommand selectCommand, string transactionID)
        {
            return ExecuteDataTable(selectCommand, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="insertCommand">Insert command.</param>
        /// <param name="updateCommand">Update command.</param>
        /// <param name="deleteCommand">Delete command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int UpdateDataTable(System.Data.DataTable dataTable, CommonCommand insertCommand, CommonCommand updateCommand, CommonCommand deleteCommand, string transactionID)
        {
            return UpdateDataTable(dataTable, insertCommand, updateCommand, deleteCommand, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="insertCommand">Insert command.</param>
        /// <param name="updateCommand">Update command.</param>
        /// <param name="deleteCommand">Delete command.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int UpdateDataTable(System.Data.DataTable dataTable, CommonCommand insertCommand, CommonCommand updateCommand, CommonCommand deleteCommand, UpdateBehavior updateBehavior, string transactionID)
        {
            return UpdateDataTable(dataTable, insertCommand, updateCommand, deleteCommand, updateBehavior, this.TransactionManager.GetTransaction(transactionID));
        }
        #endregion

        #region Paging Operation 
        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, int startRecord, int maxRecords, string transactionID)
        {
            return Fill(dataTable, startRecord, maxRecords, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, string[] columnNames, int startRecord, int maxRecords, string transactionID)
        {
            return Fill(dataTable, columnNames, startRecord, maxRecords, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, CommonCommand conditionCommand, int startRecord, int maxRecords, string transactionID)
        {
            return Fill(dataTable, conditionCommand, startRecord, maxRecords, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, string[] columnNames, CommonCommand conditionCommand, int startRecord, int maxRecords, string transactionID)
        {
            return Fill(dataTable, columnNames, startRecord, maxRecords, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(int startRecord, int maxRecords, string transactionID)
        {
            return GetData(startRecord, maxRecords, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(string[] columnNames, int startRecord, int maxRecords, string transactionID)
        {
            return GetData(columnNames, startRecord, maxRecords, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(CommonCommand conditionCommand, int startRecord, int maxRecords, string transactionID)
        {
            return GetData(conditionCommand, startRecord, maxRecords, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(string[] columnNames, CommonCommand conditionCommand, int startRecord, int maxRecords, string transactionID)
        {
            return GetData(columnNames, conditionCommand, startRecord, maxRecords, this.TransactionManager.GetTransaction(transactionID));
        }
        #endregion

        #region View Mode
        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetViewData(CommonCommand conditionCommand, string transactionID)
        {
            return this.GetViewData(conditionCommand, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetViewData(string[] columnNames, CommonCommand conditionCommand, string transactionID)
        {
            return this.GetViewData(columnNames, conditionCommand, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int FillView(System.Data.DataTable dataTable, CommonCommand conditionCommand, string transactionID)
        {
            return this.FillView(dataTable, conditionCommand, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int FillView(System.Data.DataTable dataTable, string[] columnNames, CommonCommand conditionCommand, string transactionID)
        {
            return this.FillView(dataTable, columnNames, conditionCommand, this.TransactionManager.GetTransaction(transactionID));
        }

        #region Normal Functions
        /// <summary>
        /// Gets the data row count according the condition.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of data rows.</returns>
        public virtual int GetViewDataCount(CommonCommand conditionCommand, string transactionID)
        {
            return this.GetViewDataCount(conditionCommand, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Gets the sum of data according the condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the sum of data.</returns>
        public virtual object GetViewSumData(string columnName, CommonCommand conditionCommand, string transactionID)
        {
            return this.GetViewSumData(columnName, conditionCommand, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Gets the avg of data according the condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the avg of data.</returns>
        public virtual object GetViewAvgData(string columnName, CommonCommand conditionCommand, string transactionID)
        {
            return this.GetViewAvgData(columnName, conditionCommand, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Get the max of data according condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the max of data.</returns>
        public virtual object GetViewMaxData(string columnName, CommonCommand conditionCommand, string transactionID)
        {
            return this.GetViewMaxData(columnName, conditionCommand, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Get the min of data according condition.
        /// </summary>
        /// <param name="columnName">Column name.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the min of data.</returns>
        public virtual object GetViewMinData(string columnName, CommonCommand conditionCommand, string transactionID)
        {
            return this.GetViewMinData(columnName, conditionCommand, this.TransactionManager.GetTransaction(transactionID));
        }
        #endregion

        #region Paging Operation 
        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetViewData(CommonCommand conditionCommand, int startRecord, int maxRecords, string transactionID)
        {
            return this.GetViewData(conditionCommand, startRecord, maxRecords, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetViewData(string[] columnNames, CommonCommand conditionCommand, int startRecord, int maxRecords, string transactionID)
        {
            return this.GetViewData(columnNames, conditionCommand, startRecord, maxRecords, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int FillView(System.Data.DataTable dataTable, CommonCommand conditionCommand, int startRecord, int maxRecords, string transactionID)
        {
            return this.FillView(dataTable, conditionCommand, startRecord, maxRecords, this.TransactionManager.GetTransaction(transactionID));
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnNames">An array of Columns.</param>
        /// <param name="conditionCommand">Condition Command.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int FillView(System.Data.DataTable dataTable, string[] columnNames, CommonCommand conditionCommand, int startRecord, int maxRecords, string transactionID)
        {
            return this.FillView(dataTable, columnNames, conditionCommand, startRecord, maxRecords, this.TransactionManager.GetTransaction(transactionID));
        }
        #endregion
        #endregion
        #endregion

        #region Extension Functions
        #region Common Methods
        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return Fill(dataTable, conditionCommand);
        }

        public ConditionExpressionCommandBuilder CreateConditionExpressionCommandBuilder(ConditionExpression conditionExpression)
        {
            Dictionary<string, System.Data.DbType> dbTypes = GetColumnsDbTypes();
            TableExpression tableExpression = GetTableExpression();
#if !(PocketPC || Smartphone || WindowsCE)
            if (this._databaseType == DatabaseType.SHAREPOINT)
            {
                return new SharePointConditionExpressionCommandBuilder(conditionExpression, dbTypes, tableExpression);
            }
            else
            {
#endif
                return new ConditionExpressionCommandBuilder(conditionExpression, dbTypes, tableExpression);
#if !(PocketPC || Smartphone || WindowsCE)
            }
#endif
        }

        private Dictionary<string, System.Data.DbType> GetColumnsDbTypes()
        {
            // TODO: 
            return this.CommandBuilder.CommonCommandBuilder.DbTypes;
        }

        private TableExpression GetTableExpression()
        {
            return new TableExpression(this.DefaultDataTableMapping.DataSetTable);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, ColumnExpression[] columnExpressions, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return Fill(dataTable, columnNames, conditionCommand);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int FillByPrimaryKey(System.Data.DataTable dataTable, object primaryKey)
        {
            return Fill(dataTable, new object[] { primaryKey });
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int FillByPrimaryKey(System.Data.DataTable dataTable, object primaryKey, ColumnExpression[] columnExpressions)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Fill(dataTable, new object[] { primaryKey }, columnNames);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(RaisingStudio.Data.Expressions.ConditionExpression conditionExpression)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return GetData(conditionCommand);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(ColumnExpression[] columnExpressions, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions); 
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return GetData(columnNames, conditionCommand);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetDataByPrimaryKey(object primaryKey)
        {
            return GetData(new object[] { primaryKey });
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetDataByPrimaryKey(object primaryKey, ColumnExpression[] columnExpressions)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return GetData(new object[] { primaryKey }, columnNames);
        }

        /// <summary>
        /// Delete data.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int DeleteByPrimaryKey(object primaryKey)
        {
            return Delete(new object[] { primaryKey });
        }

        /// <summary>
        /// Delete the data according the condition.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Delete(RaisingStudio.Data.Expressions.ConditionExpression conditionExpression)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return Delete(conditionCommand);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int UpdateByPrimaryKey(object primaryKey, object[] values)
        {
            return Update(new object[] { primaryKey }, values);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int UpdateByPrimaryKey(object primaryKey, ColumnExpression[] columnExpressions, object[] values)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(new object[] { primaryKey }, columnNames, values);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int UpdateByPrimaryKey(object primaryKey, Dictionary<string, object> values)
        {
            return Update(new object[] { primaryKey }, values);
        }

        /// <summary>
        /// Update the data according the condition.
        /// </summary>
        /// <remarks>
        /// Pay attention to the parameter name in the addtion condtion.
        /// </remarks>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, object[] values)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return Update(conditionCommand, values);
        }

        /// <summary>
        /// Update the data according the condition.
        /// </summary>
        /// <remarks>
        /// Pay attention to the parameter name in the addtion condtion.
        /// </remarks>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, ColumnExpression[] columnExpressions, object[] values)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return Update(conditionCommand, columnNames, values);
        }

        /// <summary>
        /// Update the data according the condition.
        /// </summary>
        /// <remarks>
        /// Pay attention to the parameter name in the addtion condtion.
        /// </remarks>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, Dictionary<string, object> values)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return Update(conditionCommand, values);
        }

        /// <summary>
        /// Check the data by primary key.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <returns>If exists then return true, otherwise return false.</returns>
        public virtual bool ExistsByPrimaryKey(object primaryKey)
        {
            return Exists(new object[] { primaryKey });
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, RaisingStudio.Data.Expressions.ColumnExpression[] columnExpressions)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Fill(dataTable, columnNames);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, object[] primaryKeys, ColumnExpression[] columnExpressions)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Fill(dataTable, primaryKeys, columnNames);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(ColumnExpression[] columnExpressions)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return GetData(columnNames);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(object[] primaryKeys, ColumnExpression[] columnExpressions)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return GetData(primaryKeys, columnNames);
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, ColumnExpression[] columnExpressions)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(dataTable, columnNames);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows, ColumnExpression[] columnExpressions)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(dataRows, columnNames);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRow">Datarow.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow dataRow, ColumnExpression[] columnExpressions)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(dataRow, columnNames);
        }

        /// <summary>
        /// Delete data.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="originalValues">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Delete(ColumnExpression[] columnExpressions, object[] originalValues)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Delete(columnNames, originalValues);
        }

        /// <summary>
        /// Insert data.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Insert(ColumnExpression[] columnExpressions, object[] values)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Insert(columnNames, values);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(ColumnExpression[] columnExpressions, object[] values)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(columnNames, values);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(object[] primaryKeys, ColumnExpression[] columnExpressions, object[] values)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(primaryKeys, columnNames, values);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="originalValues">The original values.</param>
        /// <param name="values">values.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(ColumnExpression[] columnExpressions, object[] originalValues, object[] values)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(columnNames, originalValues, values);
        }

        #region Normal Functions
        /// <summary>
        /// Gets the data row count according the condition.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>The count of data rows.</returns>
        public virtual int GetDataCount(ConditionExpression conditionExpression)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return GetDataCount(conditionCommand);
        }
     
        /// <summary>
        /// Gets the data row count according the condition.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>The count of data rows.</returns>
        public virtual long GetDataLongCount(ConditionExpression conditionExpression)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return GetDataLongCount(conditionCommand);
        }

        /// <summary>
        /// Gets the sum of data.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <returns>the sum of data.</returns>
        public virtual object GetSumData(ColumnExpression columnExpression)
        {
            string columnName = (string)columnExpression;
            return GetSumData(columnName);
        }

        /// <summary>
        /// Gets the sum of data according the condition.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>the sum of data.</returns>
        public virtual object GetSumData(ColumnExpression columnExpression, ConditionExpression conditionExpression)
        {
            string columnName = (string)columnExpression;
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return GetSumData(columnName, conditionCommand);
        }

        /// <summary>
        /// Gets the avg of data.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <returns>the avg of data.</returns>
        public virtual object GetAvgData(ColumnExpression columnExpression)
        {
            string columnName = (string)columnExpression;
            return GetAvgData(columnName);
        }

        /// <summary>
        /// Gets the avg of data according the condition.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>the avg of data.</returns>
        public virtual object GetAvgData(ColumnExpression columnExpression, ConditionExpression conditionExpression)
        {
            string columnName = (string)columnExpression;
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return GetAvgData(columnName, conditionCommand);
        }

        /// <summary>
        /// Gets the max of data.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <returns>the max of data.</returns>
        public virtual object GetMaxData(ColumnExpression columnExpression)
        {
            string columnName = (string)columnExpression;
            return GetMaxData(columnName);
        }

        /// <summary>
        /// Get the max of data according condition.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>the max of data.</returns>
        public virtual object GetMaxData(ColumnExpression columnExpression, ConditionExpression conditionExpression)
        {
            string columnName = (string)columnExpression;
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return GetMaxData(columnName, conditionCommand);
        }

        /// <summary>
        /// Gets the min of data.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <returns>the min of data.</returns>
        public virtual object GetMinData(ColumnExpression columnExpression)
        {
            string columnName = (string)columnExpression;
            return GetMinData(columnName);
        }

        /// <summary>
        /// Get the min of data according condition.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>the min of data.</returns>
        public virtual object GetMinData(ColumnExpression columnExpression, ConditionExpression conditionExpression)
        {
            string columnName = (string)columnExpression;
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return GetMinData(columnName, conditionCommand);
        }
        #endregion

        #region 并发冲突及Update 行为
        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, ColumnExpression[] columnExpressions, bool checkConcurrency)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(dataTable, columnNames, checkConcurrency);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows, ColumnExpression[] columnExpressions, bool checkConcurrency)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(dataRows, columnNames, checkConcurrency);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRow">Datarow.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow dataRow, ColumnExpression[] columnExpressions, bool checkConcurrency)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(dataRow, columnNames, checkConcurrency);
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, ColumnExpression[] columnExpressions, UpdateBehavior updateBehavior)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(dataTable, columnNames, updateBehavior);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows, ColumnExpression[] columnExpressions, UpdateBehavior updateBehavior)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(dataRows, columnNames, updateBehavior);
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, ColumnExpression[] columnExpressions, bool checkConcurrency, UpdateBehavior updateBehavior)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(dataTable, columnNames, checkConcurrency, updateBehavior);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows, ColumnExpression[] columnExpressions, bool checkConcurrency, UpdateBehavior updateBehavior)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(dataRows, columnNames, checkConcurrency, updateBehavior);
        }
        #endregion

        #region Paging Operation 
        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, ColumnExpression[] columnExpressions, int startRecord, int maxRecords)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Fill(dataTable, columnNames, startRecord, maxRecords);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, ConditionExpression conditionExpression, int startRecord, int maxRecords)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return Fill(dataTable, conditionCommand, startRecord, maxRecords);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, ColumnExpression[] columnExpressions, ConditionExpression conditionExpression, int startRecord, int maxRecords)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Fill(dataTable, columnNames, startRecord, maxRecords);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(ColumnExpression[] columnExpressions, int startRecord, int maxRecords)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return GetData(columnNames, startRecord, maxRecords);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(ConditionExpression conditionExpression, int startRecord, int maxRecords)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return GetData(conditionCommand, startRecord, maxRecords);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(ColumnExpression[] columnExpressions, ConditionExpression conditionExpression, int startRecord, int maxRecords)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return GetData(columnNames, conditionCommand, startRecord, maxRecords);
        }
        #endregion

        #region View Mode
        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetViewData(ConditionExpression conditionExpression)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.GetViewData(conditionCommand);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetViewData(ColumnExpression[] columnExpressions, ConditionExpression conditionExpression)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.GetViewData(columnNames, conditionCommand);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int FillView(System.Data.DataTable dataTable, ConditionExpression conditionExpression)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.FillView(dataTable, conditionCommand);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int FillView(System.Data.DataTable dataTable, ColumnExpression[] columnExpressions, ConditionExpression conditionExpression)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.FillView(dataTable, columnNames, conditionCommand);
        }

        #region Normal Functions
        /// <summary>
        /// Gets the data row count according the condition.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>The count of data rows.</returns>
        public virtual int GetViewDataCount(ConditionExpression conditionExpression)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.GetViewDataCount(conditionCommand);
        }

        /// <summary>
        /// Gets the sum of data according the condition.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>the sum of data.</returns>
        public virtual object GetViewSumData(ColumnExpression columnExpression, ConditionExpression conditionExpression)
        {
            string columnName = (string)columnExpression;
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.GetViewSumData(columnName, conditionCommand);
        }

        /// <summary>
        /// Gets the avg of data according the condition.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>the avg of data.</returns>
        public virtual object GetViewAvgData(ColumnExpression columnExpression, ConditionExpression conditionExpression)
        {
            string columnName = (string)columnExpression;
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.GetViewAvgData(columnName, conditionCommand);
        }

        /// <summary>
        /// Get the max of data according condition.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>the max of data.</returns>
        public virtual object GetViewMaxData(ColumnExpression columnExpression, ConditionExpression conditionExpression)
        {
            string columnName = (string)columnExpression;
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.GetViewMaxData(columnName, conditionCommand);
        }

        /// <summary>
        /// Get the min of data according condition.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <returns>the min of data.</returns>
        public virtual object GetViewMinData(ColumnExpression columnExpression, ConditionExpression conditionExpression)
        {
            string columnName = (string)columnExpression;
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.GetViewMinData(columnName, conditionCommand);
        }
        #endregion

        #region Paging Operation 
        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetViewData(ConditionExpression conditionExpression, int startRecord, int maxRecords)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.GetViewData(conditionCommand, startRecord, maxRecords);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetViewData(ColumnExpression[] columnExpressions, ConditionExpression conditionExpression, int startRecord, int maxRecords)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.GetViewData(columnNames, conditionCommand, startRecord, maxRecords);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int FillView(System.Data.DataTable dataTable, ConditionExpression conditionExpression, int startRecord, int maxRecords)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.FillView(dataTable, conditionCommand, startRecord, maxRecords);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int FillView(System.Data.DataTable dataTable, ColumnExpression[] columnExpressions, ConditionExpression conditionExpression, int startRecord, int maxRecords)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.FillView(dataTable, columnNames, conditionCommand, startRecord, maxRecords);
        }
        #endregion
        #endregion
        #endregion
        #region Transaction
        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, string transactionID)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return Fill(dataTable, conditionCommand, transactionID);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        ///  /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, ColumnExpression[] columnExpressions, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return Fill(dataTable, columnNames, conditionCommand, transactionID);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int FillByPrimaryKey(System.Data.DataTable dataTable, object primaryKey, string transactionID)
        {
            return Fill(dataTable, new object[] { primaryKey }, transactionID);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="primaryKey">The value of primary key.</param>
        ///  /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int FillByPrimaryKey(System.Data.DataTable dataTable, object primaryKey, ColumnExpression[] columnExpressions, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Fill(dataTable, new object[] { primaryKey }, columnNames, transactionID);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, string transactionID)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return GetData(conditionCommand, transactionID);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        ///  /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(ColumnExpression[] columnExpressions, RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return GetData(columnNames, conditionCommand, transactionID);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetDataByPrimaryKey(object primaryKey, string transactionID)
        {
            return GetData(new object[] { primaryKey }, transactionID);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        ///  /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetDataByPrimaryKey(object primaryKey, ColumnExpression[] columnExpressions, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return GetData(new object[] { primaryKey }, columnNames, transactionID);
        }

        /// <summary>
        /// Delete data.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int DeleteByPrimaryKey(object primaryKey, string transactionID)
        {
            return Delete(new object[] { primaryKey }, transactionID);
        }

        /// <summary>
        /// Delete the data according the condition.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Delete(RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, string transactionID)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return Delete(conditionCommand, transactionID);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int UpdateByPrimaryKey(object primaryKey, object[] values, string transactionID)
        {
            return Update(new object[] { primaryKey }, values, transactionID);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        ///  /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int UpdateByPrimaryKey(object primaryKey, ColumnExpression[] columnExpressions, object[] values, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(new object[] { primaryKey }, columnNames, values, transactionID);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int UpdateByPrimaryKey(object primaryKey, Dictionary<string, object> values, string transactionID)
        {
            return Update(new object[] { primaryKey }, values, transactionID);
        }

        /// <summary>
        /// Update the data according the condition.
        /// </summary>
        /// <remarks>
        /// Pay attention to the parameter name in the addtion condtion.
        /// </remarks>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, object[] values, string transactionID)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return Update(conditionCommand, values, transactionID);
        }

        /// <summary>
        /// Update the data according the condition.
        /// </summary>
        /// <remarks>
        /// Pay attention to the parameter name in the addtion condtion.
        /// </remarks>
        /// <param name="conditionExpression">Condition expression</param>
        ///  /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, ColumnExpression[] columnExpressions, object[] values, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return Update(conditionCommand, columnNames, values, transactionID);
        }

        /// <summary>
        /// Update the data according the condition.
        /// </summary>
        /// <remarks>
        /// Pay attention to the parameter name in the addtion condtion.
        /// </remarks>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(RaisingStudio.Data.Expressions.ConditionExpression conditionExpression, Dictionary<string, object> values, string transactionID)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return Update(conditionCommand, values, transactionID);
        }

        /// <summary>
        /// Check the data by primary key.
        /// </summary>
        /// <param name="primaryKey">The value of primary key.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>If exists then return true, otherwise return false.</returns>
        public virtual bool ExistsByPrimaryKey(object primaryKey, string transactionID)
        {
            return Exists(new object[] { primaryKey }, transactionID);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
         /// <param name="transactionID">The ID of transaction.</param>
       /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, RaisingStudio.Data.Expressions.ColumnExpression[] columnExpressions, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Fill(dataTable, columnNames, transactionID);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, object[] primaryKeys, ColumnExpression[] columnExpressions, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Fill(dataTable, primaryKeys, columnNames, transactionID);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(ColumnExpression[] columnExpressions, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return GetData(columnNames, transactionID);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(object[] primaryKeys, ColumnExpression[] columnExpressions, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return GetData(primaryKeys, columnNames, transactionID);
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, ColumnExpression[] columnExpressions, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(dataTable, columnNames, transactionID);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows, ColumnExpression[] columnExpressions, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(dataRows, columnNames, transactionID);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRow">Datarow.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow dataRow, ColumnExpression[] columnExpressions, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(dataRow, columnNames, transactionID);
        }

        /// <summary>
        /// Delete data.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="originalValues">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Delete(ColumnExpression[] columnExpressions, object[] originalValues, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Delete(columnNames, originalValues, transactionID);
        }

        /// <summary>
        /// Insert data.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Insert(ColumnExpression[] columnExpressions, object[] values, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Insert(columnNames, values, transactionID);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(ColumnExpression[] columnExpressions, object[] values, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(columnNames, values, transactionID);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="primaryKeys">The value of primary key.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(object[] primaryKeys, ColumnExpression[] columnExpressions, object[] values, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(primaryKeys, columnNames, values, transactionID);
        }

        /// <summary>
        /// Update data.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="originalValues">The original values.</param>
        /// <param name="values">values.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(ColumnExpression[] columnExpressions, object[] originalValues, object[] values, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(columnNames, originalValues, values, transactionID);
        }

        #region Normal Functions
        /// <summary>
        /// Gets the data row count according the condition.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of data rows.</returns>
        public virtual int GetDataCount(ConditionExpression conditionExpression, string transactionID)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return GetDataCount(conditionCommand, transactionID);
        }

        /// <summary>
        /// Gets the sum of data.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the sum of data.</returns>
        public virtual object GetSumData(ColumnExpression columnExpression, string transactionID)
        {
            string columnName = (string)columnExpression;
            return GetSumData(columnName, transactionID);
        }

        /// <summary>
        /// Gets the sum of data according the condition.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the sum of data.</returns>
        public virtual object GetSumData(ColumnExpression columnExpression, ConditionExpression conditionExpression, string transactionID)
        {
            string columnName = (string)columnExpression;
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return GetSumData(columnName, conditionCommand, transactionID);
        }

        /// <summary>
        /// Gets the avg of data.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the avg of data.</returns>
        public virtual object GetAvgData(ColumnExpression columnExpression, string transactionID)
        {
            string columnName = (string)columnExpression;
            return GetAvgData(columnName, transactionID);
        }

        /// <summary>
        /// Gets the avg of data according the condition.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the avg of data.</returns>
        public virtual object GetAvgData(ColumnExpression columnExpression, ConditionExpression conditionExpression, string transactionID)
        {
            string columnName = (string)columnExpression;
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return GetAvgData(columnName, conditionCommand, transactionID);
        }

        /// <summary>
        /// Gets the max of data.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the max of data.</returns>
        public virtual object GetMaxData(ColumnExpression columnExpression, string transactionID)
        {
            string columnName = (string)columnExpression;
            return GetMaxData(columnName, transactionID);
        }

        /// <summary>
        /// Get the max of data according condition.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the max of data.</returns>
        public virtual object GetMaxData(ColumnExpression columnExpression, ConditionExpression conditionExpression, string transactionID)
        {
            string columnName = (string)columnExpression;
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return GetMaxData(columnName, conditionCommand, transactionID);
        }

        /// <summary>
        /// Gets the min of data.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the min of data.</returns>
        public virtual object GetMinData(ColumnExpression columnExpression, string transactionID)
        {
            string columnName = (string)columnExpression;
            return GetMinData(columnName, transactionID);
        }

        /// <summary>
        /// Get the min of data according condition.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the min of data.</returns>
        public virtual object GetMinData(ColumnExpression columnExpression, ConditionExpression conditionExpression, string transactionID)
        {
            string columnName = (string)columnExpression;
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return GetMinData(columnName, conditionCommand, transactionID);
        }
        #endregion

        #region 并发冲突及Update 行为
        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, ColumnExpression[] columnExpressions, bool checkConcurrency, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(dataTable, columnNames, checkConcurrency, transactionID);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows, ColumnExpression[] columnExpressions, bool checkConcurrency, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(dataRows, columnNames, checkConcurrency, transactionID);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRow">Datarow.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow dataRow, ColumnExpression[] columnExpressions, bool checkConcurrency, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(dataRow, columnNames, checkConcurrency, transactionID);
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, ColumnExpression[] columnExpressions, UpdateBehavior updateBehavior, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(dataTable, columnNames, updateBehavior, transactionID);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows, ColumnExpression[] columnExpressions, UpdateBehavior updateBehavior, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(dataRows, columnNames, updateBehavior, transactionID);
        }

        /// <summary>
        /// Update Datatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataTable dataTable, ColumnExpression[] columnExpressions, bool checkConcurrency, UpdateBehavior updateBehavior, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(dataTable, columnNames, checkConcurrency, updateBehavior, transactionID);
        }

        /// <summary>
        /// Update Datarow.
        /// </summary>
        /// <param name="dataRows">Array of DataRows.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="checkConcurrency">Check concurrency.</param>
        /// <param name="updateBehavior">Update behavior</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of rows that updated.</returns>
        public virtual int Update(System.Data.DataRow[] dataRows, ColumnExpression[] columnExpressions, bool checkConcurrency, UpdateBehavior updateBehavior, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Update(dataRows, columnNames, checkConcurrency, updateBehavior, transactionID);
        }
        #endregion

        #region Paging Operation 
        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, ColumnExpression[] columnExpressions, int startRecord, int maxRecords, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Fill(dataTable, columnNames, startRecord, maxRecords, transactionID);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, ConditionExpression conditionExpression, int startRecord, int maxRecords, string transactionID)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return Fill(dataTable, conditionCommand, startRecord, maxRecords, transactionID);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int Fill(System.Data.DataTable dataTable, ColumnExpression[] columnExpressions, ConditionExpression conditionExpression, int startRecord, int maxRecords, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return Fill(dataTable, columnNames, startRecord, maxRecords, transactionID);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(ColumnExpression[] columnExpressions, int startRecord, int maxRecords, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            return GetData(columnNames, startRecord, maxRecords, transactionID);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(ConditionExpression conditionExpression, int startRecord, int maxRecords, string transactionID)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return GetData(conditionCommand, startRecord, maxRecords, transactionID);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetData(ColumnExpression[] columnExpressions, ConditionExpression conditionExpression, int startRecord, int maxRecords, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return GetData(columnNames, conditionCommand, startRecord, maxRecords, transactionID);
        }
        #endregion

        #region View Mode
        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetViewData(ConditionExpression conditionExpression, string transactionID)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.GetViewData(conditionCommand, transactionID);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetViewData(ColumnExpression[] columnExpressions, ConditionExpression conditionExpression, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.GetViewData(columnNames, conditionCommand, transactionID);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int FillView(System.Data.DataTable dataTable, ConditionExpression conditionExpression, string transactionID)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.FillView(dataTable, conditionCommand, transactionID);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int FillView(System.Data.DataTable dataTable, ColumnExpression[] columnExpressions, ConditionExpression conditionExpression, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.FillView(dataTable, columnNames, conditionCommand, transactionID);
        }

        #region Normal Functions
        /// <summary>
        /// Gets the data row count according the condition.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The count of data rows.</returns>
        public virtual int GetViewDataCount(ConditionExpression conditionExpression, string transactionID)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.GetViewDataCount(conditionCommand, transactionID);
        }

        /// <summary>
        /// Gets the sum of data according the condition.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the sum of data.</returns>
        public virtual object GetViewSumData(ColumnExpression columnExpression, ConditionExpression conditionExpression, string transactionID)
        {
            string columnName = (string)columnExpression;
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.GetViewSumData(columnName, conditionCommand, transactionID);
        }

        /// <summary>
        /// Gets the avg of data according the condition.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the avg of data.</returns>
        public virtual object GetViewAvgData(ColumnExpression columnExpression, ConditionExpression conditionExpression, string transactionID)
        {
            string columnName = (string)columnExpression;
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.GetViewAvgData(columnName, conditionCommand, transactionID);
        }

        /// <summary>
        /// Get the max of data according condition.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the max of data.</returns>
        public virtual object GetViewMaxData(ColumnExpression columnExpression, ConditionExpression conditionExpression, string transactionID)
        {
            string columnName = (string)columnExpression;
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.GetViewMaxData(columnName, conditionCommand, transactionID);
        }

        /// <summary>
        /// Get the min of data according condition.
        /// </summary>
        /// <param name="columnExpression">Column expression.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>the min of data.</returns>
        public virtual object GetViewMinData(ColumnExpression columnExpression, ConditionExpression conditionExpression, string transactionID)
        {
            string columnName = (string)columnExpression;
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.GetViewMinData(columnName, conditionCommand, transactionID);
        }
        #endregion

        #region Paging Operation 
        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetViewData(ConditionExpression conditionExpression, int startRecord, int maxRecords, string transactionID)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.GetViewData(conditionCommand, startRecord, maxRecords, transactionID);
        }

        /// <summary>
        /// Gets Datatable.
        /// </summary>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>Datatable.</returns>
        public virtual System.Data.DataTable GetViewData(ColumnExpression[] columnExpressions, ConditionExpression conditionExpression, int startRecord, int maxRecords, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.GetViewData(columnNames, conditionCommand, startRecord, maxRecords, transactionID);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int FillView(System.Data.DataTable dataTable, ConditionExpression conditionExpression, int startRecord, int maxRecords, string transactionID)
        {
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.FillView(dataTable, conditionCommand, startRecord, maxRecords, transactionID);
        }

        /// <summary>
        /// FillDatatable.
        /// </summary>
        /// <param name="dataTable">Datatable.</param>
        /// <param name="columnExpressions">An array of column expressions.</param>
        /// <param name="conditionExpression">Condition expression</param>
        /// <param name="startRecord">The zero-based record number to start with. </param>
        /// <param name="maxRecords">The maximum number of records to retrieve. </param>
        /// <param name="transactionID">The ID of transaction.</param>
        /// <returns>The number of rows successfully added to or refreshed. This does not include rows affected by statements that do not return rows.</returns>
        public virtual int FillView(System.Data.DataTable dataTable, ColumnExpression[] columnExpressions, ConditionExpression conditionExpression, int startRecord, int maxRecords, string transactionID)
        {
            string[] columnNames = ConditionExpressionCommandBuilder.GetColumnNamesFromColumnExpressions(columnExpressions);
            RaisingStudio.Data.Common.Builders.Expressions.ConditionExpressionCommandBuilder conditionExpressionCommandBuilder = CreateConditionExpressionCommandBuilder(conditionExpression);
            CommonCommand conditionCommand = conditionExpressionCommandBuilder.GetExpressionCommand();
            return this.FillView(dataTable, columnNames, conditionCommand, startRecord, maxRecords, transactionID);
        }
        #endregion
        #endregion
        #endregion
        #endregion
    }
}
